https://issues.apache.org/bugzilla/show_bug.cgi?id=53992
Priority: P2 Bug ID: 53992 Assignee: dev@poi.apache.org Summary: java.lang.RuntimeException: WINDOW2 was not found (Empty sheet) Severity: normal Classification: Unclassified OS: Linux Reporter: pedro.t.gar...@gmail.com Hardware: PC Status: NEW Version: 3.8 Component: HSSF Product: POI I get this exception: java.lang.RuntimeException: WINDOW2 was not found at org.apache.poi.hssf.model.InternalSheet.<init>(InternalSheet.java:326) at org.apache.poi.hssf.model.InternalSheet.createSheet(InternalSheet.java:163) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:296) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:88) I debbuged InternalSheet to see why this was happening. And found that the excel file I'm processing ends with an empty sheet which only contains one BOF and one EOF records. These are the last line of the BiffViewer output: Offset=0x00008DA3(36259) recno=1907 sid=0x0809 size=0x0010(16) [BOF RECORD] .version = 0x0600 .type = 0x1000 (#error unknown type#) .build = 0x15EC .buildyear= 1997 .history = 0x0000C0C1 .reqver = 0x00000306 [/BOF RECORD] Offset=0x00008DB7(36279) recno=1908 sid=0x000A size=0x0000(0) [EOF] [/EOF] So in InternalSheet(RecordStream rs) constructor, the following code throws the exception. if (windowTwo == null) { throw new RuntimeException("WINDOW2 was not found"); } I would like to know if this WINDOW2 record is mandatory when the sheet is empty. Excel and LibreOffice open the file without problems (they just don't display the empty sheet). I have fixed the error replacing the mentioned lines with the following and it seems to be working perfectly: if (windowTwo == null) { if (rra != null) { throw new RuntimeException("WINDOW2 was not found"); } log.log(POILogger.ERROR, "WINDOW2 record not found. Trying to add one with default values"); windowTwo = createWindowTwo(); records.add(findFirstRecordLocBySid(EOFRecord.sid), windowTwo); } Please, let me know if this solution is right or there is any other workaround or I should contact the creators of the excel file to ask them to fix it on their software. Thank you. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org