phpexcel sample test generates corrupt file

Topics: Developer Forum, User Forum
Feb 26, 2010 at 9:31 AM
Edited Feb 26, 2010 at 9:32 AM

I just downloaded the latest version of phpexcel(1.7.2). I have Php version 5.2.8, Office 2007, Windows Xp SP3. I tried running the 01sample.php file from the Tests folder, without modifying anything, got no error, the 01sample.xlsx file was generated, 7kb, so some content was written, but when I try to open, i get a corrupt file message: "Excel found unreadable want to save contents of workbook? Yes/No and clicking on Yes only throws a message that file is corrupt". I uploaded the 01sample.xlsx file if anyone thinks it might help. I also asked a different colleague that has office2007 to open same file and got the same error so I'm guessing it's not my office installation.

Excel file generated:

Anyone knows what might cause this?

Thanks in advance.

Feb 26, 2010 at 9:10 PM

Can you try opening the file in a text or hex editor, and let us know what the first few characters of the file contain? Or upload trhe generated file to the relevant upload item in the issue tracker? Thanks.

Mar 1, 2010 at 10:11 AM

After opening the excel file with notepad++ i can see first chars are:


also with basic notepad, first characters are PK and then some squares that probably represents symbols that notepad can't read.

Does that help?

Mar 16, 2010 at 10:25 AM

PHP 5.2.8 for Windows contains a defect php_zip.dll module responsible for creating corrupt zip files (xlsx files are zip files).

If you don't want to upgrade the whole PHP installation you can just grab php_zip.dll from PHP 5.2.6, PHP 5.2.9 or later and replace it with the one you have.

Mar 19, 2010 at 3:31 PM

Hi koyama,

This sounds a lot like my issue (, although I'm on a different version of Windows.  Those are the same characters that my corrupted files start with (see my uploaded file in the list at

I had read this post while researching my own issue, and I've upgraded to php 5.3.2 - is there a way to confirm the version of php_zip.dll that is being used is the updated one?  phpinfo says the following:



Zip enabled
Extension Version $Id: php_zip.c 294817 2010-02-09 17:51:39Z pajoye $
Zip version 1.9.1
Libzip version 0.9.0


Mar 19, 2010 at 3:46 PM

I've noticed that other people seem to have a version of zip of 2.0.0 - maybe the windows PHP installer is not installing the newer version of zip or something?  I will try manually installing the highest version of php_zip.dll I can find...

Mar 19, 2010 at 9:17 PM

Thinking about this further, my issue does not sound the same as this - .xslx files saved to the hard disk are openable with no issues, which would indicate that my php_zip.dll is probably not the issue.  Sorry...

May 20, 2010 at 9:52 PM

Hi Rick Pelletier, did you find what your issue was ? I have the same problem you do: the .XLS document written to disk are perfectly readable but the one sent over to the browser has those PK characters.

Many thanks,

Jul 9, 2010 at 6:41 PM
Edited Jul 9, 2010 at 7:37 PM
I'm having the same issue.
I have read that zip functionality is compiled into the application and the ini switch just enables zip output.

Maybe php_zip.dll is no longer provided?

I have 5.3.1, distributed with WAMP Server and there is no php_zip.dll located anywhere on my machine.

Seems it is only happening when you DOWNLOAD the file and not when you SAVE the file, too.
Could the problem possibly be in the writer's save functionality?