【发布时间】:2016-08-02 12:21:21
【问题描述】:
我正在使用 PHP 动态生成一个表格,用户可以将其下载为 .xls 文件。使用 IE 时,单击链接后,会弹出“您要打开还是保存文件...”对话框。如果用户保存文件并打开它,则没有问题。但如果用户选择“打开”,Excel 会启动,但它是空的。没有电子表格。在 Chrome 和 FF 中一切正常。
这是我正在使用的代码。
<?PHP
// filename for download
$filename = "filename" . date('M_j_Y') . ".xls";
//create the output
$output = //<table> code goes here.
//set the header to treat this as an excel file
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
echo $output;
exit;
?>
当我单击链接下载电子表格,然后从 IE10 对话框中选择“打开”时,就会发生这种情况。
任何有关如何在 IE 用户单击“打开”时打开电子表格的建议将不胜感激。谢谢。
【问题讨论】:
标签: php excel internet-explorer