If I save it to file:
$objWriter->save("test.xls");
And then download from server, I can open file without any problems.
But when I try to save into php://output
, got corrupted file like described in this question.
I tried this:
ob_end_clean();
header( "Content-type: application/vnd.ms-excel" );
header('Content-Disposition: attachment; filename="test.xls"');
header("Pragma: no-cache");
header("Expires: 0");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
exit;
ob_end_clean();
doesn't help.
I tried PHPExcel_Writer_Excel2007
and PHPExcel_Writer_Excel5
. Same problem.
UPD: as I can see, excell file has BOM at start ("EF BB BF"). But I've checked all my script, they don't have BOM symbol. So, does it means that PXPExcell add BOM?
I added ob_end_clean();
also after headers section. And BOM symbol disappeared.
ob_end_clean();
header( "Content-type: application/vnd.ms-excel" );
header('Content-Disposition: attachment; filename="test.xls"');
header("Pragma: no-cache");
header("Expires: 0");
ob_end_clean();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With