public function XLSXExporter::save in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/XLSXExporter.php \AKlump\LoftDataGrids\XLSXExporter::save()
Save as a file to the server
Parameters
string $filename: The correct extension will be appended to this string
mixed $page_id: (Optional) Defaults to NULL. Set this to export a single page.
Overrides Exporter::save
File
- vendor/
aklump/ loft_data_grids/ src/ AKlump/ LoftDataGrids/ XLSXExporter.php, line 135
Class
- XLSXExporter
- Class XLSXExporter
Namespace
AKlump\LoftDataGridsCode
public function save($filename = '', $page_id = NULL) {
// Make sure we have rendered the data
if (empty($this->output)) {
$this
->compile($page_id);
}
// Assure the correct file extension
if ($filename) {
$this
->setFilename($filename);
}
$filename = $this
->getFilename();
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $this->filename . '"');
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007');
$objWriter
->save('php://output');
exit;
}