2

私は1つのxlsbを持っています。(ms Excel 2007) ファイルが作成されました。

私はそれをサーバーにアップロードし、ウェブサイトのユーザーはそれをダウンロードできますが、ユーザーがこのファイルをダウンロードして開くと、MS Excel は「はい」をクリックすると「Excel で読み取り不能なコンテンツが見つかりました」というエラーが表示されます。このエラーが表示される理由がわかりません。

次に、このxlsbファイルをgmailとyahoomailから送信しました。ダウンロードして開くと、すべて問題なく、エラーメッセージも表示されません。

このエラーを修正するのを手伝ってください。サーバー側の言語として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をダウンロードできるWebページです

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

4

1 に答える 1

1

私はあなたが提供したファイルをチェックしました、そしてエラーが何であるかをはっきりとあなたに言うことができます:どういうわけか現在のウェブサイトはこのバイナリファイルにも追加されます。(HTML部分を切り取ると、ファイルは修復ダイアログなしで開きます)。

exitしたがって、これについての私の最善の推測は、 readfileの後のステートメントを忘れたということです。

コードは次のようになります。

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

これにより、Webサイトがダウンロードファイルに追加されるのを防ぎます。

于 2013-01-24T12:26:34.780 に答える