Reputation: 5891
I've followed some tutorials and saw some people with same issue but I can't figure out how to put this working on my project.
Btw, I'm using CodeIgniter framework and I have Excel 2007 in my computer.
public function exportExcel(){
require(APPPATH . 'libraries/toExcel/PHPExcel.php');
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello');
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('Simple');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header('Content-Type: application/vnd.ms-excel; charset=utf-8');
header('Content-Disposition: attachment; filename=01simple.xls');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
exit;
}
This is my code just for testings. Whenever I download the file generated by that function and try to open it is this what I get:
And when I click "Yes" I receive this:
Upvotes: 0
Views: 4164
Reputation: 1
All php_excel changed Unknown Creator worksheet. directory application/third_party/phpexcel/PHPExcel/DocumentProperties.php changed line 43;
private $creator = 'Unknown Creator'; changed ↓
private $creator = 'your name';
Upvotes: 0
Reputation: 5891
Solved.
ob_end_clean();
ob_start();
$objWriter->save('php://output');
Upvotes: 8