How to solve PHPExcel fatal error: Uncaught exception 'PHPExcel_Writer_Exception' with message 'Could not close zip'

This exception is basically generated when PHPExcel is unable to write to the specified file or write to the directory that will contain the file, so to troubleshoot this problem you may want to follow these steps:

  1. Check that the directory that you are trying to write exists. You may do this with a tool, via CLI or even with a conditional statement in PHP.
  2. Permissions problems. If the file exists, check if the user that executes the script has access to the directory where the file should be written to (have the open_basedir in count).
  3. Block issue when the file has been opened by another application.
  4. Disk space problem, if the disk that you are tryng to write the file doesn't have available space, you will be unable to create the file.

Is important that you follow the steps in the given order until you find out what's the reason why the file cannot be created.

Happy coding !

This could interest you

Become a more social person