PHPExcel $objWriter->save() fails

纵饮孤独 提交于 2019-12-24 00:59:01

问题


I am creating an Excel file based on records from a database with PHPExcel and am facing an odd problem when generating it on a large data set. I have narrowed it down to a single problem-causing line:

$objWriter->save('php://output');

It just spits out a blank file instead of the expected workbook. Also, the effect is similar if I try to save the result into a local file instead of redirecting to the browser - no file is ever created.

The kicker is that it works perfectly for a smaller data set (smaller = up to 200 rows, larger = up to 2000 rows, up to 20 columns in both cases). It also works fine on another (development) server with an EXACT SAME, 100% identical, large dataset.

I do have the save() call wrapped in a try-catch but no exception is raised. Executing memory_get_peak_usage() right before going for save() tells me that it was using 24MB, and I have ini_set('memory_limit', '-1') earlier in the script. Also, monitoring memory usage on the server while running the script does not show any significant increase either.

Any tips for debugging it?

Edit: there are no errors in apache logs, however I did notice that the relevant line in access logs says:

10.1.1.1 - - [01/Jun/2011:08:35:03 -0400] "GET /get_excel.php HTTP/1.1" 200 16386

The odd part is the last column - size. The file I actually get to download is always empty - exactly 0 bits, not 16386.


回答1:


Based on the feedback you gave in the comments I think you do not meet all the requirements. You can find the list of the requirements here on the phpexcel website.



来源:https://stackoverflow.com/questions/6201176/phpexcel-objwriter-save-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!