简体   繁体   English

ms excel 2007 xlsb文件下载不可读内容错误

[英]xlsb file download unreadable content error with ms excel 2007

I have one xlsb. 我有一个xlsb。 (ms excel 2007) file created. (ms excel 2007)文件已创建。

I have uploaded it to server and user of website can download it but when user download and open this file ms excel prompted with error as "Excel found unreadable content" when they click on yes everything is ok. 我已将其上载到服务器,网站的用户可以下载它,但是当用户下载并打开此文件时,ms excel会提示错误,并单击“是,发现Excel内容不可读”,一切正常。 I don't know why this error displayed. 我不知道为什么显示此错误。

Then I have sent this xlsb file from gmail and yahoomail and when download and open everything is ok and no any error message. 然后,我从gmail和yahoomail发送了这个xlsb文件,下载并打开时一切正常,没有任何错误消息。

so please help me to rectify this error. 因此,请帮助我纠正此错误。 I am using php as my server side language and download code is below 我使用php作为服务器端语言,下载代码如下

header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    //header('Content-type: application/octet-stream');
    //header('Content-type: application/vnd.ms-excel.sheet.binary.macroEnabled.12');

    header('Content-Disposition: attachment; filename="credit-card-payoff.xlsb"');

    readfile('exporting/excel/credit-card-payoff.xlsb');

I have tried different content-type but didn't success. 我尝试了不同的内容类型,但没有成功。

below is webpage from user can download excel 以下是用户可以下载的网页

http://utc.impexdirectory.com/credit-card-payoff-calculator.php http://utc.impexdirectory.com/credit-card-payoff-calculator.php

I have checked the file you provided and can tell you definitely what the error is: Somehow the current website gets appended to this binary-file as well. 我已经检查了您提供的文件,并且可以肯定地告诉您错误是什么:当前网站也以某种方式被附加到此二进制文件中。 (If I cutoff the HTML part the file opens without the repair dialogue). (如果我截断了HTML部分,则文件打开而没有修复对话框)。

So my best guess for this is, you forgot the exit statement after readfile. 因此,我对此的最佳猜测是,您在readfile之后忘记了exit语句。

Your code should read like this: 您的代码应如下所示:

header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment; filename="credit-card-payoff.xlsb"');

readfile('exporting/excel/credit-card-payoff.xlsb');
exit(0); // Terminate the program execution at this point

This prevents that the website gets appended to the download file. 这样可以防止将网站附加到下载文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM