Bug 8542 - write on xls with aggregrate row fails.
Summary: write on xls with aggregrate row fails.
Status: RESOLVED FIXED
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
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-26 07:37 UTC by Mani
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

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
("costpool.xls"));
	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(cell1.getNumericCellValue());
	System.out.println(cell2.getNumericCellValue());

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

	double num = 100;
	cell1.setCellValue(num);	

	System.out.println(cell1.getNumericCellValue());
	System.out.println(cell2.getNumericCellValue());



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


StackTrace
----------

Exception in thread "main" java.lang.NullPointerException
        at org.apache.poi.hssf.record.FormulaRecord.getTotalPtgSize
(FormulaRecord.java:363)
        at org.apache.poi.hssf.record.FormulaRecord.serialize
(FormulaRecord.java:335)
        at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.serialize
(ValueRecordsAggregate.java:174)
        at org.apache.poi.hssf.model.Sheet.serialize(Sheet.java:584)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes
(HSSFWorkbook.java:513)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.write
(HSSFWorkbook.java:465)
        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.