|Summary:||[PATCH] Sheet is corrupted after changing a template with POI|
|Product:||POI||Reporter:||Jan Tilo <jan-tilo>|
|Component:||HSSF||Assignee:||POI Developers List <dev>|
The template file
...the corrupted file
Process continuation records as standalone records if after unknown records
Description Jan Tilo 2003-02-25 14:09:00 UTC
I have a Excelsheet which I want to edit and save. After I saved the Sheet it couldn't be read by Excel. I think the problem is, that the Sheet contains elements like text-/comboboxes and labels. The problem also accures, when I open the File with POI an save it back without changing something.
Comment 3 Csaba 2003-02-25 15:09:19 UTC
This behavior also happened to me. I'm not sure if you have the same problem, but I found the following to be the cause: - if there is an unknown record, any following continuation records will be dropped. This happens with records which are not handled by POI, and contain a lot of data (like images). The solution would be to keep all continuation records after an unknown record and serialize them back as they are, otherwise the file gets corrupted... I have corrected this problem for my own use in version 1.5.1-final-20021120, but I have no experience in creating/submitting patches. If you can assist me a bit I could send a patch...
Comment 4 Avik Sengupta 2003-02-25 15:32:06 UTC
It would be great if you would submit this patch. The basic procedure is documented in http://jakarta.apache.org/poi/getinvolved/index.html. The idea is to get the latest source from cvs (see http://jakarta.apache.org/site/cvsindex.html), make your changes, run "build.sh/.bat test", run "cvs -u diff>mypatch.patch", and upload mypatch.patch to bugzilla as an attachement to this bug. Please ask on the dev list if you need any more help.
Comment 5 Csaba 2003-02-26 11:03:32 UTC
Created attachment 5034 [details] Process continuation records as standalone records if after unknown records
Comment 6 Csaba 2003-02-26 11:04:19 UTC
Added patch. See if it is in a usable form, this is my first patch ever ;) Note that the event model will still mishandle unknown records, as it is filtering out any unknown records unless the listener is explicitly registered to receive all record sids it wants to pass through... the null parameter for record sids to be processed will default to the list of known records. In my opinion this is not the best behavior, as there's no way to specify "pass through all records, even if unknown". The current behavior ("pass through all known records") can be achieved easily by passing EventRecordFactory.getAllKnownRecordSIDs() when registering the filter.
Comment 7 Csaba 2003-03-04 10:16:53 UTC
Guys, I need some feedback on what I did here... this patch makes me able to use the POI library to open complex templates and modify just a few rows. I need the functionality incorporated in future versions if I want to ever upgrade. Please let me know if it is acceptable as it is, or it needs some more work.
Comment 8 Avik Sengupta 2003-03-04 14:41:03 UTC
I am happy to commit this. Adding patch to the summary is a good step in keeping it in sight :)
Comment 9 Avik Sengupta 2003-03-07 15:52:31 UTC
Applied. Thanks. Could you please cross check. Csaba, i would suggest you open a new issue with an RFE on changing the behaviour of Event Model.
Comment 10 Csaba 2003-03-07 17:15:13 UTC
Thanks. I can't check it any time soon, I've just switched to Linux as a development OS and I'm afraid OpenOffice will handle things differently... In any case, the template I was playing with gives me some other error now due to the new (presumably incomplete) formula handling code of the CVS tip. I also don't have time right now for POI, the 1.5 version works now for what we are using it. As soon as I'll finish my current personal project (some 1-2 months) I plan to spend some more time with POI. Thanks again !
Comment 11 David Rosenborg 2003-04-17 16:33:31 UTC
I can confirm that it now handles a roundtrip of an image I placed in the top left cell. However, any programatic additions of cells that I make after reading the template are lost. I found a workaround though: If I include a non empty cell in the template after the image, things work fine. So it seems that reading the image cell leaves the sheet in a somewhat instable state but it can be stabilized reading just another text cell.