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