使用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