Tutorial :Fatal error: Uncaught exception 'Exception' in PHPExcel classes


Can any one please let me know, why this following error has been thrown from PHPExcel classes

    Fatal error: Uncaught exception 'Exception' with message 'Could not close zip file   /var/www/mydomain/myexcel.xlsx.' in /var/www/mydomain/Classes/PHPExcel/Writer  /Excel2007.php:400 Stack trace: #0 /var/www/mydomain/myexcel.php(173):   PHPExcel_Writer_Excel2007->save('/var/www/mydomain...') #1 {main}   thrown in /var/www/mydomain/Classes/PHPExcel/Writer/Excel2007.php on line 400  


I hope this exception may occur because of the Excel sheet is still in open state. also please check with the permission of the folder in which you write/save/upload the .xlsx file.


My educated guess would be that this is due to the fact that the permissions on the folder you're trying to write to are wrong. If that's the case, either make the folder writable (which, from the looks of it would be a bad idea) - or try to save to a location where the web user has write access to solve the problem.

BTW What version of PHPExcel are you using?


The most likely cause of this error is that you do not have permission to write to the directory you're trying to save the Excel file to.


The exception is being thrown because PHPExcel has opened the zip file for writing the Excel workbook; but when it tries to close it again on completion, the zip library method call to close() has failed. Why it has failed is the real problem, and that can't be resolved simply by knowing the error message.


I had this same problem - here is how I solved it: Traditionally PHP runs as the web server daemon, so it would stand to reason that the web server daemon would need to write in that subdir and should be the group owner of the entire Examples subdir. I made that simple change and it worked perfectly.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »