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

Bug #12848 Excel "File Error: data may have been lost."
Submitted: 2008-01-08 07:14 UTC
From: maartenba Assigned:
Status: Open Package: Spreadsheet_Excel_Writer (version CVS)
PHP Version: 5.2.4 OS: Any
Roadmaps: (Not assigned)    
Subscription  


 [2008-01-08 07:14 UTC] maartenba (Maarten Balliauw)
Description: ------------ I tried using Spreadsheet_Excel_Writer to generate an XLS file, but when I open the file in Excel 2007 I first get the following alert box: "File Error: data may have been lost." Note that this happens even for "blank" spreadsheets. After clicking "OK" I see no problems with the file, though. The same behavior is seen in Excel 2003 Service Pack 3. Before upgrading Microsoft Office 2003 with service pack 3 there was no such problem. Others seem to have similar problems with other packages (perhaps similar code) http://groups.google.com/group/spreadsheet-writeexcel/browse_thread/thread/6656856820b6f799/ From what I read, the problem is that Excel 2007 is no longer compatible with Excel 95 spreadsheets, but only with Excel 97 spreadsheets and up. Same is the case for Excel 2003 with SP3. Is there a workaround to this problem? I wouldn't mind sacrificing Excel 95 support. Test script: --------------- Examples: * Trying with a workbook with a single blank worksheets gives error * adding 1 non-empty cell fixes the error * again, adding 1 extra blank worksheet makes error reappear

Comments

 [2008-01-08 11:14 UTC] dufuz (Helgi Þormar Þorbjörnsson)
SP3 actually prevented office to open up older formats, both theirs and by other companies, 24 formats in total but they have been under pressure of providing a easy way to revert that, atm you can do so via a registry hack. I'm not deep enough into this whole excel world to know but yeah I think we can safely drop excel 95 support, perhaps via an option so that people that want that support just have to turn it on.
 [2008-01-08 12:35 UTC] dufuz (Helgi Þormar Þorbjörnsson)
Just so you have a reference: http://www.news.com/Microsoft-admits-Office-2003-mistake/2100-1012_3-6224917.html but of course a simple google search suffices.
 [2008-04-18 14:45 UTC] robbertwethmar (Robbert Wethmar)
I had the same problem. MS knowledgebase issue 938810 describes it and has registry hacks, but they don't help me :-( Removing Office updates is not possble either (MS advises to uninstall & reinstall). Open office reads the file just fine, but i have to make it work in Excell 2003 too :-(
 [2008-05-15 00:42 UTC] johou (Jo Hou)
Sorry, My English is poor! My environments are PHP4.1 and Spreadsheet_Excel_Writer 2.1 . I have got the coding reasion : Example: /* insert a blank in a cell */ $worksheet->writeBlank(0,2,$format_title4); /*The same cell have been insert into repeatedly*/ $worksheet->writeString(0,2,"SOMESTRING",$format_title4); The same cell have been insert into repeatedly that induced 'File Error: data may have been lost.'. Change it . The Error will not show!
 [2008-06-10 20:01 UTC] mimeks (Mimeks Mimeks)
Yes, this is true. Rewriting cells induce to "File error". So what happens if i need rewrite some cells? I can't change the logic of my report. I hope somebody had a better solution. Greetings... mimeks!
 [2008-06-12 14:01 UTC] robbertwethmar (Robbert Wethmar)
Rewriting cells could VERY well be the problem: for me it ONLY occurs in reports were i rewrite cells. Rewriting them is not simple unfortunately
 [2008-06-16 13:13 UTC] robbertwethmar (Robbert Wethmar)
first i tried to write a wrapper class to fix the problem, that didn't work, so i changed the pear lib itself. (worksheet.php). I only patched writeNumber, writeString and writeFormula, and didn't bother to do a full rewrite (yet). This fixes my problem for now, because i only use those three functions to put data in the sheet... Doing this however, i REALLY verified the rewriting of cells is the problem. By rewriting the same cell ends up in the file multiple times. My patch avoids that, by storing the cells in memory and only writing to file on close. So its a proof of concept, this solution works but might be a bit difficult to implement in full.
 [2009-05-15 11:17 UTC] kewlbuddy (kewl buddy)
Thanks 'johou', The error solved: Need to change excel generation code. So that, you not re-write the cell again and again. Example: /* insert a blank in a cell */ $worksheet->writeBlank(0,2,$format); then according to condition write text in the same cell $worksheet->writeString(0,2,"Testing Text",$format); As a result File error get removed.
 [2009-11-14 00:38 UTC] iterator (Nonya Business)
I am getting this same error message, but it's not because I'm rewriting cells. The error message is unexplained. I've had success in stopping the error only by reducing the amount of iterations on the loop(s) where the error happens. But that is not a solution because the data actually does become lost.
 [2010-01-26 02:29 UTC] mfeldman (Michael Feldman)
This problem also occurs if you have empty worksheets in a workbook.
 [2013-04-10 20:14 UTC] pierre42 (Pierre Beaumadier)
I have the same problem here despite having no blank cell at all...