phpexcel在苹果手机safari浏览器上导出excel总是带有.html后缀的解决办法

phpexcel导出excel的时候,加上下面这几行代码,设置一下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-Disposition:attachment;filename=filename.xlsx");
header("Content-Transfer-Encoding:binary");

并且在最后save之后,记得exit终止程序

$objWrite->save('php://output');
exit();

这样操作后,phpexcel在苹果手机safari浏览器上导出excel的时候就不会再带有.html后缀了。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: