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