在自己本地导出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.'"');