public function XLSXExporter::saveFile in Loft Data Grids 7.2
Compile and and save to a filepath.
Parameters
string $directory A writable directory in which to save the file.:
null $filename:
null $page_id:
Return value
mixed
Overrides Exporter::saveFile
File
- vendor/
aklump/ loft_data_grids/ src/ AKlump/ LoftDataGrids/ XLSXExporter.php, line 151
Class
- XLSXExporter
- Class XLSXExporter
Namespace
AKlump\LoftDataGridsCode
public function saveFile($directory, $filename = '', $page_id = null) {
// Go through the setter to ensure the file_extension.
$filename = $filename ? $this
->setFilename($filename) : $this
->getFilename();
if (!is_writable($directory)) {
throw new \RuntimeException("{$directory} is not writable; cannot save {$filename}.");
}
// Make sure we have rendered the data
if (empty($this->output)) {
$this
->compile($page_id);
}
$path = $directory . '/' . $filename;
$objWriter = \PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007');
$objWriter
->save($path);
return $path;
}