【发布时间】:2012-05-30 08:18:24
【问题描述】:
xlsx 文件不能在 IE 中下载,但在 Firefox 中可以正常工作 我的代码是
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header("Content-Disposition: attachment;filename='Monthly-Report-$month-$year'");
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
//$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
exit;
错误信息在 IE 中显示为 Internet Explorer 无法下载 xlsx.php(这是我编写代码的 php 文件) Internet Explorer 无法打开此站点
【问题讨论】:
-
您在使用 SSL 吗?正如这篇支持知识库文章总结的那样,带有 SSL 的缓存控制标头存在问题 - support.microsoft.com/kb/323308。此外,您可以查看在 SO - stackoverflow.com/questions/2232103/… 上发布的类似回复。您可能只需要调整标头,我认为如果您在 SSL 上尝试这样做会很好。
标签: php excel-2007 phpexcel