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)
please check against the CVS head. We'll be putting out a new release candidate shortly. Experimental formula parsing will be properly disabled.
Please test this against the CVS head or a nightly build -- we've added formula support that should handle this.
This should now work against both CVS HEAD and 1.5. The stated problem is formula related and has been fixed.