Bug 8542 - write on xls with aggregrate row fails.
Summary: write on xls with aggregrate row fails.
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2002-04-26 07:37 UTC by Mani
Modified: 2005-03-20 17:06 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Mani 2002-04-26 07:37:30 UTC
Hi, this is my xls
  A      B
1 Cost   Amount
2 T1     20
3 T2     30
4 T3     20
5 Total  =B2+B3+B4 

This is the java code,XLTest.java. Here I am reading B3 , changing its value to 
100, and writing back the xls to see if B5 gives the right aggregate. 
Unfortunately i get a NullPointerException and also the xls file turns empty. I 
am including the stacktrace below. It would be very helpful if you can fix this 
or tell a work around.

POIFSFileSystem fs      =
				new POIFSFileSystem(new FileInputStream
	HSSFWorkbook wb = new HSSFWorkbook(fs);
	HSSFSheet sheet = wb.getSheetAt(0);
	HSSFRow row1 = sheet.getRow(2);
	HSSFCell cell1 = row1.getCell((short)1);

	HSSFRow row2 = sheet.getRow(4);
	HSSFCell cell2 = row2.getCell((short)1);

	System.out.println("original values");


	System.out.println("ok.....am changing the above values");

	double num = 100;


	// Write the output to a file
    FileOutputStream fileOut = new FileOutputStream("costpool.xls");


Exception in thread "main" java.lang.NullPointerException
        at org.apache.poi.hssf.record.FormulaRecord.getTotalPtgSize
        at org.apache.poi.hssf.record.FormulaRecord.serialize
        at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.serialize
        at org.apache.poi.hssf.model.Sheet.serialize(Sheet.java:584)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.write
        at XLTest.main(XLTest.java:41)
Comment 1 Andy Oliver 2002-04-26 12:20:17 UTC
please check against the CVS head.  We'll be putting out a new release candidate
shortly.  Experimental formula parsing will be properly disabled.
Comment 2 Andy Oliver 2002-05-10 02:34:04 UTC
Please test this against the CVS head or a nightly build -- we've added formula
support that should handle this.
Comment 3 Avik Sengupta 2002-06-11 21:27:22 UTC
This should now work against both CVS HEAD and 1.5. The stated problem is 
formula related and has been fixed.