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> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | brett.knights, ncsaba |
Priority: | P3 | ||
Version: | 2.0-dev | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: |
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
Created attachment 5003 [details]
The template file
Created attachment 5004 [details]
...the corrupted file
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... 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. Created attachment 5034 [details]
Process continuation records as standalone records if after unknown records
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. 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. I am happy to commit this. Adding patch to the summary is a good step in keeping it in sight :) 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. 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 ! 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. *** Bug 19739 has been marked as a duplicate of this bug. *** |