I am receiving a NullPointerException when I call Workbook.write(). The trace is below. I've also attached the method in which I call write(). java.lang.NullPointerException .at org.apache.poi.hssf.record.SSTSerializer.calculateUnicodeSize (SSTSerializer. .at org.apache.poi.hssf.record.SSTRecordSizeCalculator.getRecordSize (SSTRecordSi .at org.apache.poi.hssf.record.SSTRecord.getRecordSize(SSTRecord.java:499) .at org.apache.poi.hssf.model.Workbook.getSize(Workbook.java:756) .at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:768) .at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:732) .at com.timeinc.tcs.compsub.admin.DisplayXLS.process(DisplayXLS.java:132) .at com.timeinc.tcs.compsub.admin.DisplayXLS.doGet(DisplayXLS.java:59) ============================================================================= public String process() throws IOException{ //System.out.println("***"+props.SHEETNAME_RPT); File temp = File.createTempFile("CSB",".xls"); temp.deleteOnExit(); try{ // SET UP WORKBOOK AND SHEETS wb = getTemplate(); setStyles(); setReportSheet(); setReportHeaderSheet(); setInstructionSheet(); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(temp)); wb.write(bos); bos.flush(); bos.close(); } catch (Exception e) { e.printStackTrace(System.out); } return temp.getCanonicalPath(); }
Apparently the calls in the stack trace no longer exist in the version in CVS HEAD. Specifically, org.apache.poi.hssf.record.SSTRecordSizeCalculator.getRecordSize() no longer has a call to rg.apache.poi.hssf.record.SSTSerializer.calculateUnicodeSize(..). The call existed in a previous version. Can you build from source and verify that the latest from CVS does not give the exception? ...or wait couple of days till the next release and test against that.
Wel this has been completely rewritten in HEAD. As amol suggested a new release is just arround the corner, or get the latest from CVS if you are game. Jason