Exception: "Could not close zip file"

Topics: User Forum
Nov 11, 2013 at 7:09 PM
Edited Nov 11, 2013 at 7:25 PM
Hi All,

I've got a site that generates spreadsheets, and I'm trying to move it to using PHPExcel (and generate XLSX files). I am using v. 1.7.9, and my staging site is hosted on my Mac using MAMP Pro. (If it matters, I loaded PHPExcel using Composer and I am using NetBeans as my development environment)

Problem is, I keep getting a file that doesn't load/display in Excel (2011 for Mac if it matters). When I check the error log, I see the following:

Uncaught exception 'PHPExcel_Writer_Exception' with message 'Could not close zip file php://output.' in [web root]/vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007.php:348

So I went back and tested one of the simple examples (01simple-download-xlsx.php) and got the same results.

A google search shows that this can be a problem with folder permissions, but I am writing to php://output so I am not sure that's the issue. I walked through the code with the debugger and in the line that throws the exception, I see that the filename member of the $objZip object (A ZipArchive object) is "[web root]/vendor/phpoffice/phpexcel/Examples/php:/output", so I went to the Examples folder and made sure everybody had read/write permissions, but the error persists.

I'm sure that it's just something I'm missing (I see so many people using it without issue) but not sure where to look next.

Any suggestions or a kick in the right direction?

Thanks!

FOLLOWUP:

I think I have resolved this issue myself. Turns out that the webserver did not have rights to the system temp folder (hence the funny filename in the ZipArchive object). When I rectified that, it came to life.

Hopefully we can leave this post here so others that might have the issue can be helped.
Marked as answer by judodan on 11/11/2013 at 11:25 AM