PHPExcel浏览器输出Excel2007出错

点此查看代码

PHPExcel_Writer_Exception with message “Could not close zip file php://output.”

PHPExcel浏览器输出Excel2007出错_第1张图片


代码中的 $objWriter->save("php://output"); 导致错误,解决如下:

<span style="white-space:pre">	</span>/*解决Excel2007不能导出*/
	function SaveViaTempFile($objWriter){
	    $filePath = '' . rand(0, getrandmax()) . rand(0, getrandmax()) . ".tmp";
	    $objWriter->save($filePath);
	    readfile($filePath);
	    unlink($filePath);
	}

点此打开原文

用上面的代码替换save方法即可 SaveViaTempFile($objWriter);

运行结果图:

PHPExcel浏览器输出Excel2007出错_第2张图片

点此打开源代码

你可能感兴趣的:(PHP,Excel)