PHP_excel:导出到xlsx已成功下载,但是当我们打开它时,它显示警告Excel发现不可读的内容 [英] PHP_excel: Export to xlsx gets downloaded successfully but when we open it it shows warning Excel found unreadable content

查看:605
本文介绍了PHP_excel:导出到xlsx已成功下载,但是当我们打开它时,它显示警告Excel发现不可读的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用php_excel导出到xlsx.在我的应用程序中,即时通讯使用模板. 当我下载文件时,xlsx文件可以很好地下载,但是当我们打开它时,显示以下警告:

i am using php_excel to export to xlsx. In my application im making use of template. When i download, the xlsx file gets downloaded fine, but when we open its showing the following warning:

" Excel在'project_report(3).xlsx'中发现了不可读的内容.是否要恢复此工作簿的内容?如果您信任此工作簿的来源,请单击是.".

如果我单击是",它将正确打开文件.

If i click yes it opens the file correctly.

还有一件事情是,当我将下载的文件附加到邮件中时.如果我用Google Spreadsheet打开它,它说格式不好,无法打开.

And one more thing is when i attach the downloaded file to the mail. And if i open it sing Google Spread sheet it says bad format unable to open.

所以如果有人知道原因,请建议我解决这个问题.

so if anyone know the reason please suggest me to solve this.

推荐答案

检查标题,这是我的:

   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/octet-stream");
   header("Content-Type: application/download");;
   header("Content-Disposition: attachment;filename=$filename");
   header("Content-Transfer-Encoding: binary");
   $objWriter->save('php://output');

检查输出(<?php之前被遗忘的echo?空格

check for output (spaces before <?php forgotten echo? etc

这篇关于PHP_excel:导出到xlsx已成功下载,但是当我们打开它时,它显示警告Excel发现不可读的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆