phpとmysqlを使用して、データベースからexcelシートにデータをエクスポートしようとしています。 IEとすべてのブラウザでlocalhostで正常に動作しますが、IEの実際のWebサイト(hostmonsterサイト)で失敗します。ファイルをダウンロードできなかったことを示します。WebサイトのIEでphp export excelが動作しない
これは、動的データを生成して、ダウンロードを提供しています、私のサンプルコードです:
<?php
while($node_stmt = mysql_fetch_array($result))
{
$contents.="\t\t".$node_stmt['uniqueid']."\t";
$contents.=$node_stmt['title'].' '.
ucfirst($node_stmt['firstname']).' '.
ucfirst($node_stmt['lastname'])."\t";
$contents.=$node_stmt1['topic']."\t";
$contents.=$abst."\t";
$contents.=$node_stmt['email']."\t";
$contents.=$node_stmt['phoneno']."\t";
$contents.=$pay."\t";
$contents.=$node_stmt['state_id']."\t";
$contents.=$node_stmt['country_id']."\n";
}
.....
header('Content-Transfer-Encoding: none');
header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
header("Content-type: application/x-msexcel"); // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
echo $contents;
?>
iは、ホストまたはIEで任意の設定を変更する必要がありますか?
application/x-msexcelをieに送信せず、代わりにapplication/vnd.ms-excelだけを送信しようとしましたか?単純に$ _SERVER ["HTTP_USER_AGENT"]をチェックしてください。 –