Bug 64420

Summary: NullPointerException in XSSFReader.SheetIterator.next() if XLSX contains a macrosheet
Product: POI Reporter: spfaffer
Component: XSSFAssignee: POI Developers List <dev>
Severity: major    
Priority: P2    
Version: 4.1.2-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Bug Depends on: 50119    
Bug Blocks:    
Attachments: xlsm file containing a macrosheet that reproduces the problem

Description spfaffer 2020-05-11 13:23:03 UTC
Created attachment 37224 [details]
xlsm file containing a macrosheet that reproduces the problem

This is almost a duplicate of the fixed bug 50119 except that my xlsm contains a macro sheet. The same analysis as in 50119 applies here.

In the constructor of XSSFReader.SheetIterator only worksheets and chartsheets are added to the sheetMap. The macro sheet (http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet) is not added to the sheetMap. But the iterator iterates over all valid IDs, including the macro sheet. Since the sheetMap doesn't contain the macro sheet this call in SheetIterator.next()

           return sheetPkg.getInputStream();

(org.apache.poi.xssf.eventusermodel.XSSFReader.SheetIterator, line 313)   

throws a NullPointer.
Comment 1 Dominik Stadler 2020-05-16 13:06:39 UTC
Fixed via r1877814 on trunk now.