Last updated
$config = ['path' => './'];
$excel = new \Vtiful\Kernel\Excel($config);
$fileHandle = $excel->fileName('tutorial.xlsx')->getHandle();
$bold = new \Vtiful\Kernel\Format($fileHandle);
$boldFmt = $bold->bold()->toResource();
$table = new \Vtiful\Kernel\Table();
$table->name('Sales')
->totalRow()
->columns([
['header' => 'Region', 'header_format' => $boldFmt, 'total_string' => 'Total'],
['header' => 'Q1', 'total_function' => \Vtiful\Kernel\Table::FUNCTION_SUM],
['header' => 'Q2', 'total_function' => \Vtiful\Kernel\Table::FUNCTION_SUM],
['header' => 'Q3', 'total_function' => \Vtiful\Kernel\Table::FUNCTION_SUM],
['header' => 'Q4', 'total_function' => \Vtiful\Kernel\Table::FUNCTION_SUM],
]);
$excel->data([
['East', 100, 110, 120, 130],
['West', 90, 95, 100, 105],
['North', 200, 210, 220, 230],
// 最后一行留给汇总行
['', 0, 0, 0, 0],
])
->addTable('A1:E5', $table)
->output();