1.出現的問題

2.導出代碼(首先聲明導出使用PHPExcel_IOFactory::createWriter($objExcel, ‘Excel5’)->save(outpath)導出正常)
`
//導出的檔案名
$outputFileName =iconv ( 'UTF-8', 'gb2312', date('Y-m-d_H-i-s',time()).'.xls' );
//檔案直接輸出到浏覽器
ob_end_clean();
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-Disposition:attachment;filename='. $outputFileName );
header ( 'Content-Transfer-Encoding:binary');
ob_end_clean();
\PHPExcel_IOFactory::createWriter($objExcel, 'Excel5')->save('php://output');
//記錄日志
$this->optionData("導出檔案",session('auth')['userName']."執行了導出檔案");
ob_end_clean();
return '0';`
3.隻要使用php://out就不能輸出檔案就出現1的情況 但是不使用php://out
就沒問題
4.現在的需求是導出時,彈出對話框讓使用者指定儲存位置,提高互動的體驗,使用 PHPExcel_IOFactory::createWriter($objExcel, ‘Excel5’)->save(outpath);
導出後儲存到public/upload下面了
5.環境 laravel 5.2 php版本5.5 win7 64bit 大概資訊就這樣 如有需要可以提供更多資訊
laravel 用的不是這個包嗎 maatwebsite/excel
Laravel 有現成封裝的 excel 的庫吧,不需要想你這麼寫吧
将第二個
ob_end_clean();
删除就好了,本地測試可以下載下傳