-
Notifications
You must be signed in to change notification settings - Fork 1
PHPExcel Generation
Darryl Hein edited this page Aug 20, 2014
·
3 revisions
Basic XLS Generation inside a controller:
Kohana::load(Kohana::find_file('vendor', 'phpexcel/PHPExcel'));
$xls = new PHPExcel();
$xls->setActiveSheetIndex(0);
$sheet = $xls->getActiveSheet();
$sheet->setTitle('Sheet');
$headings = array(
array(
'name' => 'Column',
'width' => 14,
),
);
XLS::add_headings($sheet, $headings);
$row_num = 2;
foreach ($array as $item) {
$row_data = array(
'',
);
XLS::add_row($sheet, $row_num, $row_data);
++ $row_num;
}
$xls->setActiveSheetIndex(0);
$output = PHPExcel_IOFactory::createWriter($xls, 'Excel2007');
$tmp_file = tempnam(NULL, 'order_export');
$output->save($tmp_file);
$user_filename = 'Name.xlsx';
$this->response
->headers('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
->send_file($tmp_file, $user_filename, array('delete' => TRUE));