/** * Generates the binary excel data * * @todo find a way to set date format for generated cells * @return string * @throws CakeException If the excel writer does not exist */ private function __output() { //remove initially created empty Sheet $this->currentSheetIndex = $this->PHPExcel->getIndex($this->PHPExcel->getSheetByName('Worksheet')); $this->PHPExcel->removeSheetByIndex($this->currentSheetIndex); $this->PHPExcel->getProperties()->setCreator(Configure::read('App.author')); $this->PHPExcel->getProperties()->setDescription('generated by ' . Configure::read('App.title')); $this->PHPExcel->getProperties()->setKeywords("office 2007 openxml php"); ob_start(); $writer = \PHPExcel_IOFactory::createWriter($this->PHPExcel, 'Excel2007'); if (!isset($writer)) { throw new Exception('Excel writer not found'); } $writer->setPreCalculateFormulas(false); $writer->setIncludeCharts(true); $writer->save('php://output'); $output = ob_get_clean(); return $output; }