升級到php7之後phpexcel匯出excel出現此問題,在php5環境下可以匯出。
code:
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);header("Pragma: public");header("Expires: 0");header("Cache-Control:must-revalidate, post-check=0, pre-check=0");header("Content-Type:application/vnd.ms-execl");header('Content-Disposition:attachment;filename="xxx.xls"');header("Content-Transfer-Encoding:binary");$objWriter->save('php://output');
回複內容:
升級到php7之後phpexcel匯出excel出現此問題,在php5環境下可以匯出。
code:
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);header("Pragma: public");header("Expires: 0");header("Cache-Control:must-revalidate, post-check=0, pre-check=0");header("Content-Type:application/vnd.ms-execl");header('Content-Disposition:attachment;filename="xxx.xls"');header("Content-Transfer-Encoding:binary");$objWriter->save('php://output');
錯誤提示:
Fatal error: 'break' not in the 'loop' or 'switch' context in Function.php
這是1.8版本運行在php7上存在的一個Bug,將phpexcel升級至1.8.1就可以了。
github的issue有沒有碰到過跟你一樣的問題的人,或者stackoverflow搜一下。我用過5下的execl沒用過7的