Corrupt files written (several formats)

Topics: Developer Forum
Sep 23, 2008 at 12:34 AM
Howdy,
  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
-xml
  libxml2 Version => 2.6.16
-zip (PECL)
  Zip version => 1.8.10
  Libzip version => 0.7.1
-gd
  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.

Developer
Sep 23, 2008 at 1: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 4:36 PM
I have sent you a message with the file URL.
Developer
Sep 23, 2008 at 9:33 PM
Thanks, I received the files. Will be following up on this.
Sep 24, 2008 at 4:58 PM
Edited Sep 24, 2008 at 4: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:

http://framework.zend.com/issues/browse/ZF-4360

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