Bug 45066

Summary: Sheet.getSize() returns wrong value when UncalcedRecord is present
Product: POI Reporter: Josh Micich <josh>
Component: HSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

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.