打赏

php导出xls,报错:文件格式和扩展名不匹配。该文件可能已损坏或不安全。除非你相信它的来源,否则不要打开它。

打开文件报错如下

在文件头加上如下代码

1 ob_end_clean();
2 header('Content-Type:application/vnd.ms-excel');
3 header('Cache-Control: max-age=0');

如下:

 

 

参考:https://www.cnblogs.com/jthb/archive/2013/05/24/3097485.html

   https://www.bobcoder.cc/index/post/detail/id/375.html

 

posted on 2019-11-25 13:57  头大的冯冯  阅读(1557)  评论(0编辑  收藏  举报

导航