1

I have following codes for exporting from my php file

 header("Content-type: application/msexcel");
 header("Content-Disposition: attachment; filename=exceldata.xls");
 header("Pragma: no-cache");
 header("Expires: 0");"

This code produces following error

The file you are trying to open is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?

Please suggest some solution?Thanks in advance!!

4

1 回答 1

2

如果您生成的文件不是 Excel BIFF 格式的文件(例如,如果它是 CSV 或 HTML 标记),您将收到此错误。要么使用可用于 PHP 的众多库之一创建正确的格式文件以生成真正的 Excel 文件,要么为您实际创建的文件使用正确的 mimetype 和扩展名。

于 2013-01-16T12:10:38.543 回答