与其将其保存到文件中,不如将其保存到
php://output文档中:
$objWriter->save('php://output');这会将它按原样发送到浏览器。
你想添加一些头文件第一,喜欢它的常见的有文件下载,因此浏览器知道哪些类型的文件,它应该如何命名(文件名):
// We'll be outputting an excel fileheader('Content-type: application/vnd.ms-excel');// It will be called file.xlsheader('Content-Disposition: attachment; filename="file.xls"');// Write file to the browser$objWriter->save('php://output');首先执行标题,然后保存。对于excel标头,还请参见以下问题:为excel文档设置mime类型。



