Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.4

Bug #4174 MS Outlook 2003 corrupts excel files generated by version .4 or later
Submitted: 2005-04-18 03:30 UTC
From: jd1 at titleoptions dot com Assigned: cschmitz
Status: Closed Package: Spreadsheet_Excel_Writer (version 0.4)
PHP Version: 5.16 OS: Windows XP
Roadmaps: (Not assigned)    
Subscription  


 [2005-04-18 03:30 UTC] jd1 at titleoptions dot com
Description: ------------ Somehow, when a sheet is generated with version .4 or later, and if the file is greater than 7MB, MS Outlook 2003 will corrupt the file if it is sent as an attachment. I realize this sounds unlikely, but I have tested it to an extreme and it definatly is happening. The Excel files generated (either as version 97 or 95) become corrupted by outlook only if using version .4 or better of the Spreadsheet_excel_writer to build the sheet. I tried version 3, 4, and 5 of the OLE to go along with this and had same result. Interestingly, if I use version .3 of the Spreadsheet_excel_writer, the issue goes away. Reproduce code: --------------- My code is rather complex and would take some work for me to take it out of its context for posting. If you need me to post something here, please contact me. Otherwise, just have a buddy with Outlook 2003 attach one of your sheets and send it. It must be attached to a new message for this to happen (fowarding a sheet does not cause the issue). Expected result: ---------------- Open one your generated sheets (must be bigger than 7MB) in excel. Opens fine right? Now attach to an Outlook 2003 message and send it. The recipient will get a corrupted file...and it is even corrupt in your sent items. Way to go MS! If anyone can verify this...please respond. Thanks. JMDill

Comments

 [2005-04-18 03:37 UTC] jd1 at titleoptions dot com
More details on the size of the file: First of all, I am meant to say 7KB not 7MB. Secondly, it may also have to do with number of rows. Seems that over 10 rows is about where the problem begins. Small sheets with just a few rows work fine.
 [2005-09-08 15:57 UTC] jd1 at titleoptions dot com
Here is the office version: Microsoft Office Outlook 2003 11.6359.6408 SP1
 [2005-11-29 10:24 UTC] krlbak at yahoo dot com
Ran into the same bug with 0.8 beta. After sending a resulting worksheet with Outlook it fails to open, whilst the original opens fine. Outlook version is the exact same as original poster: Microsoft Office Outlook 2003 11.6359.6408 SP1
 [2006-02-08 13:40 UTC] czapel at go2 dot pl
I have the same problem. My files are significantly smaller. I have generated some files with size of 40kb and they were also corrupted if I send them using MS Outlook. I use Outlook 2003 (11.8002.6568) SP2. My colleague uses Outlook 2002 10.6515.6735 SP3 and has also this problem. Regards cZaPeL
 [2006-07-17 21:16 UTC] daniel dot oprean at yahoo dot com (Daniel Oprean)
I am stuck with the same problem with 0.9 beta. Seems that files with many different cell formats are affected by this bug. Seems that outlook adds some garbages at xls attachments (don't know why ... this information isn't available anywhere in ms specs) and somehow it affects the data in the file. If you just simply open that file with excel and save it before attaching it, this problem dissappear. Could it be something about BIFF header max length?
 [2007-03-19 19:03 UTC] unk1911 (Mike Melamed)
same problem for me with 0.9.1 (beta). i'm on Microsoft Outlook 2003 (11.6568.8107) SP2
 [2007-05-13 20:59 UTC] pasty901 (Helen Staddon)
Exactly the same trouble here with version 0.9.1. Larger file sizes seem to cause the trouble...if anyone has a fix would be most appreciative. Thanks Helen
 [2007-07-20 18:25 UTC] stevew (Steve Wendt)
Outlook 2007 also corrupts these Excel attachments. It happens with files as small as 60KB (maybe even smaller?).
 [2007-10-02 18:24 UTC] garethj (Gareth Jones)
The reason Excel writer produced spreadsheets could be sent using Outlook in version 0.3 and not since then could possibly be due to version 0.3 being the last version to use its own OLE functionality. Version 0.4 and later use the external OLE pear module. Will look into this further as creating excel files that can't be emailed using Outlook is pretty useless...
 [2007-10-06 13:43 UTC] garethj (Gareth Jones)
Managed to create a less buggy release than 0.9.1 by extracting the relevant Excel5 and OLE classes from http://www.codeplex.com/PHPExcel (which is based on the code from here) and applied a few modifications to support PHP4 (PHPExcel is PHP5 only). The release ixed the following: * a couple of memory leaks that affect large files * Outlook attachment corruption * setVersion(8) and UTF input encoding bug. I will get around to releasing this sometime over the next month or so once I've cleaned things up a bit, but if you just want some working PHP-4 excel creation pear modules in the meantime, just send me an email.
 [2007-10-06 15:57 UTC] jd1 at titleoptions dot com
Awesome! Thank you for addressing this. Personally, I am not so concerned with PHP 4 support. - Jeremy Dill
 [2007-11-06 13:33 UTC] garethj (Gareth Jones)
Not so much a patch but I've hacked together a new 0.9.1 release with some bug fixes, one of which includes support generated files to be attached to emails via Outlook. You can get it from: http://projects.flignet.org/files/Spreadsheet_Excel_Writer-0.9.1flignet1.tgz This version does not depend upon the OLE package.
 [2007-11-06 20:16 UTC] stevew (Steve Wendt)
Unfortunately, OLEwriter does not work for large spreadsheets. Rather than replacing the whole package, here's an easy guide for getting it working for the small spreadsheets (i.e. stop Outlook from trashing them), while still allowing large spreadsheets to be created: 1) Download OLEwriter from CVS (direct link follows), and put into the PEAR/Spreadsheet/Excel/Writer directory. http://cvs.php.net/viewvc.cgi/pear/Spreadsheet_Excel_Writer/Spreadsheet/Excel/Writer/OLEwriter.php?revision=1.1 2) Modify PEAR/Spreadsheet/Excel/Writer/Workbook.php as follows: a) Add the following line with the other require_once lines: require_once 'Spreadsheet/Excel/Writer/OLEwriter.php'; b) Find the function _storeOLEFile(), around line 585 c) Add the following code to the beginning of the function: // OLEwriter has a size limit if ($this->_biffsize <= 7087104) { $OLE = new Spreadsheet_Excel_Writer_OLEwriter($this->_filename); $this->_tmp_filename = $OLE->_tmp_filename; $OLE->setSize($this->_biffsize); $OLE->writeHeader(); $OLE->write($this->_data); foreach($this->_worksheets as $sheet) { while ($tmp = $sheet->getData()) { $OLE->write($tmp); } } $OLE->close(); } else { // Use the OLE PEAR module d) At the end of the function (should be around line 629 now), add a closing brace: return true; } } Obviously, the real fix is to figure out what is wrong with the PEAR OLE class, but this workaround helps in the meantime.
 [2007-11-15 15:19 UTC] joeattrends (Joe Richardson)
I haven't done any development using PEAR modules but I have run across this problem with incoming excel spreadsheets from companies I do business with. This is the only place I have seen discussion on the topic, but I wanted to check is the problem present with the outgoing email through outlook or is it the receiver's outlook and could it quickly be circumvented by opening email through a web portal instead of using the outlook client. Also is the current release of the excel writer the 9.1 version spoken of with the patch/hack/fix in it? and also can this be fixed by downgrading to version .3 and if so what functionality could they lose, as I am going to recommend they change the version of this writer if they use it.
 [2007-11-15 17:20 UTC] garethj (Gareth Jones)
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). So yes the problem is on the sender side and not the receiver.
 [2007-11-15 18:33 UTC] jd1 at titleoptions dot com
You can use the version .3 to gen pretty good sheets. That is what I have been doing for a while (since my original post). However, some features are not available...and the version of the file created is excel 5 i believe, so you will always be asked to save the file no matter if you changed it or not (until it is converted to newer version). I haven't tried the methods provided by Gareth or Steve yet, but they seem to correspond with what I had assumed to be the problem years ago (the OLE) so I am willing to bet that they would work to get you going on 9+. I have to say, this is an awesome utility and I am very grateful to its authors. - Jeremy
 [2007-12-29 02:08 UTC] stevew (Steve Wendt)
I just updated to the latest PEAR OLE library (version 0.6.1), and some quick tests suggest this problem may be fixed. Anyone else have positive or negative results to report?
 [2009-08-12 12:44 UTC] progi1984 (Franck Lefevre)
-Status: Open +Status: Feedback -Package Version: +Package Version: 0.4
Thank you for taking the time to report a problem with the package. Unfortunately you are not using a current version of the package -- the problem might already be fixed. Please download a new version from http://pear.php.net/packages.php If you are able to reproduce the bug with one of the latest versions, please change the package version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PEAR.
 [2009-11-29 06:46 UTC] cschmitz (Carsten Schmitz)
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: cschmitz
Closed due to missing feedback. Please re-open if you can still reproduce the problem on the latest version.