在php7之前是可以正常导出的,在php7中使用save(‘php://output’)出现ERR_INVALID_RESPONSE的错误主要是下面错误导致。
和缓冲区的错误导致,下面示例代码可以正常导出:
header('Content-type: application/-excel;charset=utf-8;name="' . $xlsTitle . '.xls"');
header("Content-Disposition: attachment; filename=$");
header('Cache-Control: max-age=0');
//header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
//header ('Cache-Control: cache, must-revalidate');
header ('Pragma: public');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
2.错误语法导致:打开PHPExcel\Calculation\文件,删除掉581行的break即可。
喜欢 (10)or分享 (0)