Corrupt files written (several formats)

Topics: Developer Forum
Sep 22, 2008 at 11:34 PM
  I am a new PHPExcel user attempting to write out excel files.  There seems to be some inconsistency with the output.  I started with Excel5 as my format and found that error free files were produced about half of the time.  Re-running the script a time or two would eventually create a good file.  These results were typical on Ubuntu/OO2.4, XP/Office2007, and Mac/Office2008.

I next tried the CSV writer, but encountered a corrupt line that would produce invalid data after a certain line number.  Lastly I used the Excel2007 format which XP/Office2007 complains is corrupt, but works on Mac/Office2008.

Generation On:
Redhat 5 (RHEL5)
PHP 5.2.6 with
  libxml2 Version => 2.6.16
-zip (PECL)
  Zip version => 1.8.10
  Libzip version => 0.7.1
  GD Version => bundled (2.0.34 compatible)

Testing Files On:
-Ubuntu 8.04 (Open Office 2.4)
-Windows XP (MS Office 2007)
-Mac (MS Office 2008)

What I do know is that my content may be a culprit.  Would whitespace chars cause CSV or Excel5 to generate corrupt files?  The CSV output would go to a certain line and be jumbled/corrupt after that.  I can only assume that the Excel5 output would be wholly invalid after a simiar error.  Should I be stripping all chars below ASCII 32?  What about international charsets?

Thank you for your help, I'm kind of stuck as to how to proceed troubleshooting from here.

Sep 23, 2008 at 12:41 AM
There could be many reasons why this is happening. Would it be possible for you to upload the broken files somewhere so we can inspect?
Sep 23, 2008 at 3:36 PM
I have sent you a message with the file URL.
Sep 23, 2008 at 8:33 PM
Thanks, I received the files. Will be following up on this.
Sep 24, 2008 at 3:58 PM
Edited Sep 24, 2008 at 3:58 PM
After further investigation I have concluded that PHPExcel is not at fault.  After passing the files through the Zend Framework's mail module and mime attachment they were being corrupted.   The issue is open with them here:

After correcting the MIME line length all my PHPExcel files are perfect.  Sorry for the false alarm and thank you for the diligent support.