problem opening generated xls files on other computers

Topics: Developer Forum, User Forum
Nov 21, 2008 at 7:27 PM
Ok, first my software specs:
wamp - php5.2.5, ms office professional 2003 with sp3, winxp sp2

i generate an xls sheet, and i can open the saved file from my hard disc of course (using excel5 writer) on my computer, but when i send the file to other people (mail or copy via memory stick), they can't open it - they get an error that excel has tried to repair the problem, but the file was corupted beyond repair, and it shuts down (ofiice 2003 sp2 and sp3).

i can not use excel2007 because of the software license isue (about 200 computer users in my firm are using office 2003 and they are happy with it, so its out of the question, and did not bother to test it).

the thing that is also funny is that when i opet the same file on my computer and save it under another name via excel - they have no problem opening the other file. The funny thing is that the generated file with the writer is about 650kb, and the same file opened and resaved by excel has a mere 50kb. this is not such a problem, but i cant belive that the writer produces 10 times more "garbage" then needed (and its not such a big sheet - 5 columns and 59 rows).

p.s. i tried to generate the test files on my computer (14excel5.php, 01simple with excel5), and have the same problem - other people cant open them ether (but i can of course???)

where is the catch?
Developer
Nov 21, 2008 at 10:37 PM
Looks like this is the same issue as was reported for PEAR Spreadsheet_Excel_Writer (which PHPExcel_Writer_Excel5 is based on):
http://pear.php.net/bugs/bug.php?id=4174

As I read what the posters are saying, the bug really lies in Outlook altering the attachment. There must be something that Outlook doesn't like about the files that the OLE writer is producing.
This needs investigation...

Before distributing the generated Excel file, I agree that it may be a good idea to do a plain save in MS Office Excel whenever you have such chance. This will give you the best chances that the Excel file will be forward compatible with future MS Office Excel versions, and compatible with other applications such as OpenOffice.org. For example, you will not be able to see images if you open your generated spreadsheet in OpenOffice.org, but after a save in MS Office Excel, you will.

P.S. The reason why file sizes are reduced after saving is probably because you have images. Excel5 writer stores images as uncompressed bitmaps, but when you save in MS Office Excel, the application will convert the image to compressed bitmap (probably PNG).


Nov 22, 2008 at 7:28 AM
Edited Nov 22, 2008 at 7:38 AM
yes, you were right - it is an outlook 2003 problem. TNX!

This is also true: "the problem seems to be with Outlook modifying attachments as part of its encoding. You can in fact send generated spreadsheets successfully using Outlook by right-clicking the file you want to send (using File Explorer) and selected "Send To" from the drop-down. This method uses a different encoding method which seems to work (unlike attaching the file from within Outlook itself)."

here is the simple and stupid workaround that will work for me though - if you zip the files, they are not altered :)
(i need to send 50 of those files as a monthly report, so zip is the method, and that will work ok for now i guess...).
Developer
Nov 28, 2008 at 4:05 AM
A work item has been created for monitoring this problem:

http://www.codeplex.com/PHPExcel/WorkItem/View.aspx?WorkItemId=8320


Developer
Nov 29, 2008 at 3:38 AM
Fixed per work item 8320:
http://www.codeplex.com/PHPExcel/WorkItem/View.aspx?WorkItemId=8320