thinkphp调用phpexcel导出excel 10
$objWriter->save('php://output');//文件通过浏览器下载这句执行不了,如果改成$objWriter->save('test.xls');这...
$objWriter->save('php://output'); //文件通过浏览器下载
这句执行不了,如果改成$objWriter->save('test.xls');这样会下载到项目的根目录下,求大神指点 展开
这句执行不了,如果改成$objWriter->save('test.xls');这样会下载到项目的根目录下,求大神指点 展开
2015-10-14 · 知道合伙人软件行家
关注
展开全部
加上header 头
$outputFileName = "新款表".date("Y-m-d H:i:s",time()).".xls";
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="'.$outputFileName.'"');
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
$objWriter->save('php://output');
exit;
追问
加上去也不行
追答
ob_end_clean();
$outputFileName = "新款表".date("Y-m-d H:i:s",time()).".xls";
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="'.$outputFileName.'"');
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
$objWriter->save('php://output');
exit;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询