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.
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.