Generatin Excel2007 problem

Topics: Developer Forum
Oct 13, 2014 at 4:21 PM
Edited Oct 13, 2014 at 4:29 PM
Hi, here is my configuration

Server : Local (Windiws 7) and IIS 6
Php : 5.3.13

Here is my code :
    $filetype = 'Excel2007';
    $writer = PHPExcel_IOFactory::createWriter($fichier, $filetype); 

    $filename = 'Projets_' .date("d-m-Y"). '.xlsx';
    header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
Here is the error thrown :
PHP Fatal error: Uncaught exception 'PHPExcel_Writer_Exception' with message 'Error zipping files : PCLZIP_ERR_MISSING_FILE (-4) : File 'C:/Windows/Temp/[Content_Types].xml' does not exist' in C:\wamp\www\blabla\library\phpexcel\PHPExcel\Shared\ZipArchive.php:108
Analysis :
When I use Excel5, the file can be generated. The problem is that I'm also generating charts and I need them with Excel2007.
When I use WAMP, the file is generated so I suppose the problem is coming from IIS but can somebody tell me why ?

I didn't find any information on
'Error zipping files : PCLZIP_ERR_MISSING_FILE (-4) : File 'C:/Windows/Temp/[Content_Types].xml'
Oct 13, 2014 at 4:53 PM
First question:

Why are you using PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);?
Oct 14, 2014 at 8:22 AM
Edited Oct 14, 2014 at 8:32 AM
Hi Mark,

I can't find the php_zip.dll in my php.ini or in my "/ext" folder. This DLL has to be enabled in order to use ZIPARCHIVE, am I right ?

I rode on SO that previous versions of PHP shipped with separate php_zip.dll file in ext folder. And we needed to enable (comment out the ;extension=php_zip.dll line in php.ini) the zip extension manually. Latest version, since PHP 5.3.0, includes this zip support in core and it is enabled by default.

I rode here that since 1.7.6 the PCLZip library has been bundled with PHPExcel as an alternative to the ZipArchive class, that's why I used it.

Everything works fine on WAMP. I only have this error with IIS : /
Oct 14, 2014 at 8:37 AM
Latest version, since PHP 5.3.0, includes this zip support in core and it is enabled by default.
If you're using PHP > 5.3, the ZipArchive class should be built into PHP core.

It's easy enough to check, just try to instantiate a ZipArchive in a script and if it succeeds then there is no need to use the external PCLZip class (which is a slow and memory-hungry alternative to that built-in ZipArchive class)
Marked as answer by ingersen on 10/14/2014 at 12:57 AM
Oct 14, 2014 at 8:39 AM
Edited Oct 14, 2014 at 8:59 AM
Yeah I'm using php 5.3.13.
I'm gonna try with ZIPARCHIVE and see what happens :)

Ok great, it works !

This is what I've done :
First, I changed PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP); for PHPExcel_Settings::setZipClass(PHPExcel_Settings::ZIPARCHIVE);

After that, I got a new error :
Could not close zip file
So I checked some topic on internet and the problem was coming from user right on the temp folder. After changing them, everything works fine.

Mark, thanks for your help :) (Excuse my english, I'm french so I try to do my best in order to be understood !)