我有一个小函数,它使用PHPexcel创建.xls文档,然后将其发送到php://output。然后用户下载它。
除了mac os x上的safari出于某种原因添加了.html扩展名之外,一切都正常。
所以结果文件命名为report.xls.html。内容是正确的,但对用户来说很烦人。
我该如何解决这个问题?
以下是我的代码的一部分:
$filename = 'report.xls';
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save('php://output');
exit;
可以解决问题吗? - cytsunny