使用phpExcel導出excel時,報500錯


在自己本地導出excel沒有問題,但是放到服務器出現500的錯誤!

解決方法:查看控制器引用的header文件,是否包含空格,如下:

   header('Pragma:public');        
        header('Expires:0');
        header('Cache  -   Control  :  must - revalidate,post  -  check  =  0,pre  -  check  =  0');    
        header('Content  -  Type  :  application  /  force-download');
        header('Content  -  Type  : application  /  vnd.ms-excel');
        header('Content  -  Type  :  application  /  octet-stream');
        header('Content  -  Type  :  application  /  download');
        header('Content  -  Transfer  -  Encoding  :  binary');
        header('Content  -  Disposition  :  attachment; filename = "' . $outputFileName . '"');

把里面的空格去掉,如下:

   header('Pragma:public');        
        header('Expires:0');
        header('Cache-Control:must-revalidate,post-check=0,pre-check=0');    
        header('Content-Type:application/force-download');
        header('Content-Type:application/vnd.ms-excel');
        header('Content-Type:application/octet-stream');
        header('Content-Type:application/download');
        header('Content-Transfer-Encoding:binary');
        header('Content-Disposition: attachment; filename="'.$outputFileName.'"');


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM