PHP Excel - 您尝试打开的文件.xls与文件扩展名指定的格式不同 [英] PHP Excel - The file you are trying to open .xls is in a different format than specified by the file extension

查看:648
本文介绍了PHP Excel - 您尝试打开的文件.xls与文件扩展名指定的格式不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早安,

我使用API​​ JASPERJasperClient.php,其中我使用函数runReport来返回一个xls和PHP代码,我想下载Excel文件从服务器。

I am use a API JASPER "JasperClient.php" where i use the function runReport to return a xls and in php code i want to download Excel File from the server.

设置标题:

头('Content-type:application / vnd .MS-的excel');
header('Content-Disposition:attachment; filename = myfile.xls');

header('Content-type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename=myfile.xls');

当我下载文件并尝试打开说明:

When i'm download the file and try to open the says:

您尝试打开的文件'filename.xls'与文件扩展名指定的格式不同。在打开文件之前验证文件是否已损坏,是否受信任的来源。你现在要打开文件吗?

The file you are trying to open, 'filename.xls', 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?

你能帮我吗?
谢谢。

Can you help me please? Thank you .

推荐答案

您是否创建Excel 2007文件?如果是,请尝试使用mimetype application / vnd.openxmlformats-officedocument.spreadsheetml.sheet和文件扩展名.xslx

Are you creating Excel 2007 files? If so try using mimetype application/vnd.openxmlformats-officedocument.spreadsheetml.sheet and file extension .xslx

这篇关于PHP Excel - 您尝试打开的文件.xls与文件扩展名指定的格式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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