DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8542>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8542

write on xls with aggregrate row fails.

           Summary: write on xls with aggregrate row fails.
           Product: POI
           Version: 1.5
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: HSSF
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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)

Reply via email to