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=27496>. 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=27496 HSSFSheet#getRowBreaks() raises NPE with a brand-new workbook Summary: HSSFSheet#getRowBreaks() raises NPE with a brand-new workbook Product: POI Version: 2.0-dev Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: HSSF AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I tried page break feature of POI-2.5-FINAL, and got trouble. I create a new workbook file with Excel and call HSSFSheet#getRowBreaks(), then it raises NullPointerException. (1) create a new workbook file (three sheets and no data) with Excel. I tried with Excel 2000 and XP. (2) create HSSFWorkbook instance for (1)'s workbook. (3) call workbook.getSheetAt() to get sheet. (4) call sheet.getRowBreaks(). It raises NPE. Environments: Windows2000 J2SE 1.4.2_03 MS Excel2000 POI-2.5-FINAL Here is the stack trace. --- java.lang.NullPointerException at org.apache.poi.hssf.model.Sheet.getNumRowBreaks(Sheet.java:2764) at org.apache.poi.hssf.usermodel.HSSFSheet.getRowBreaks(HSSFSheet.java: 1144) at POISample.handleSheet(POISample.java:41) at POISample.main(POISample.java:26) Exception in thread "main" --- and sample code --- public class POISample { public static void main(final String[] args) throws Exception { final HSSFWorkbook book = new HSSFWorkbook(new FileInputStream(args[0])); POISample.handleSheet(book.getSheetAt(0)); book.write(new FileOutputStream(args[1])); } private static void handleSheet(final HSSFSheet sheet) { for (int i = 0; i < 5; ++i) { final HSSFRow row = sheet.createRow(i); for (short j = 0; j < 5; ++j) { final HSSFCell cell = row.createCell(j); cell.setCellValue(i + ":" + j); } } final int[] breaks = sheet.getRowBreaks(); sheet.setRowBreak(1); } } --- Additionally, in some cases i succeeded calling getRowBreaks(). If the sheet already has some page breaks, or the sheet is created with HSSFWorkbook#createSheet(), it succeeds. kind regards. IRIE Hironori --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
