Bug 45066 - Sheet.getSize() returns wrong value when UncalcedRecord is present
Summary: Sheet.getSize() returns wrong value when UncalcedRecord is present
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-05-22 20:45 UTC by Josh Micich
Modified: 2008-05-22 21:02 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Josh Micich 2008-05-22 20:45:57 UTC
This bug is one of a few noticed while working on bug 45046.

Inspection of Sheet.getSize() and Sheet.serialize() shows that the presence of UncalcedRecord is handled differently.  The discrepancy causes wrong offset values to be encoded into BoundSheetRecord.  If there is more than one sheet, Excel will report errors and loose data when trying to open the book.

To reproduce: Create a spreadsheet in Excel with 2 sheets. Change the workbook settings for 'recalculation' to 'manual' and uncheck the 'recalculate before save' option.  Add any formula to the first sheet. Save. Read with POI and write back. Open in Excel. boom.

Perhaps the biggest problem here is that HSSFWorkbook asks all the sheets for their sizes, but then doesn't care how much space they take when they are serialized.
Comment 1 Josh Micich 2008-05-22 21:02:55 UTC
Fixed in svn r659403.

HSSFWorkbook was modified to always check that the return values from sheet.getSize() match those from sheet.serialize().

Sheet was modified to handle UncalcedRecord consistently.

Junits were added for both changes.