XLSB文件下载不可读的内容错误与ms excel 2007


xlsb file download unreadable content error with ms excel 2007

我有一个xlsb。(ms excel 2007)文件创建。

我已经把它上传到服务器,网站的用户可以下载它,但是当用户下载并打开这个文件时,ms excel提示错误为"excel发现不可读的内容",当他们点击是,一切正常。我不知道为什么会出现这个错误。

然后我已经从gmail和雅虎邮件发送了这个xlsb文件,当下载和打开一切都是好的,没有任何错误信息。

所以请帮我纠正这个错误。我使用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');

我尝试了不同的内容类型,但都没有成功。

下面是网页,用户可以下载excel

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

我已经检查了您提供的文件,可以明确地告诉您错误是什么:以某种方式当前网站也附加到这个二进制文件中。(如果我切断HTML部分,文件打开没有修复对话框)。

所以我最好的猜测是,您忘记了readfile后面的exit语句。

你的代码应该是这样的:
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

防止网站被附加到下载文件。