Bug 8360

Summary: Excel-Sheet can not write out, if original one contains a formula
Product: POI Reporter: Dietmar Gausselmann <dietmar.gausselmann>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P3    
Version: 2.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Dietmar Gausselmann 2002-04-22 07:08:30 UTC
If you open an existing excel and you will add that with some data from your 
java program, it will fail if the excel file contains a formula.

Exception in thread "main" java.lang.NullPointerException
        at org.apache.poi.hssf.record.FormulaRecord.getTotalPtgSize
(FormulaRecord.java, Compiled Code)
        at org.apache.poi.hssf.record.FormulaRecord.serialize
(FormulaRecord.java:335)
        at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.serialize
(ValueRecordsAggregate.java, C
ompiled Code)
        at org.apache.poi.hssf.model.Sheet.serialize(Sheet.java, Compiled Code)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes
(HSSFWorkbook.java, Compiled Code)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.write
(HSSFWorkbook.java:465)
        at XmlWriteToExcel.closeWriteSheets(XmlWriteToExcel.java:194)
        at XmlWriteToExcel.mapFiles(XmlWriteToExcel.java:223)
        at XmlWriteToExcel.main(XmlWriteToExcel.java:290)

I tried to read out every sheet, row and cell, to populate the values, but 
without success.
Comment 1 Andy Oliver 2002-04-22 13:36:39 UTC
Please try the CVS head.  We'll be releaseing 1.5-final with experimental
formula support disabled (meaning HSSF will ignore formulas and write them
exactly as it found them).  The head should have this in place.  
Comment 2 Glen Stampoultzis 2002-04-23 13:11:18 UTC
Actually, the 1.5 branch would be the correct place to try this out.
Comment 3 Dietmar Gausselmann 2002-05-06 18:06:30 UTC
It still not working with the 1.5 final.
The exception is gone but the fomular is not computed.

xls1 -> continas a formular on B2 to sum the values form A9:A14

I fill the cells with POI, set to NUMERIC, save xls1 to xls2 and open xls2.
I see all values inside A9:A14 but the cell B2 show "0".
I can't get it to work.
Is it a bug, feature, unsorported or user error?
Comment 4 Andy Oliver 2002-05-10 02:36:53 UTC
That is the correct behavior for 1.5 (not to screw it up).  Check against the
CVS head or a nightly build and see if it does what you expect.  Formulas are a
2.0 feature.
Comment 5 Avik Sengupta 2002-06-11 21:25:00 UTC
I dont think this should be an issue any longer. 

1.5 has NO formula support, so use it if you sheet has formulas, but your java 
code does not want to do anything to it. 

2.0-dev HAS formula support, and can now indeed write out it the original sheet 
has a formula.