diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 979e81ce54..c27545d3cf 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,7 +34,7 @@ - + 50119 - avoid NPE when XSSFReader comes across chart sheets 50075 - avoid NPE in ListLevel.getNumberText() when numberText is null diff --git a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java index 991d6661d3..0994ad8500 100644 --- a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java +++ b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java @@ -177,7 +177,8 @@ public class XSSFReader { //step 1. Map sheet's relationship Id and the corresponding PackagePart sheetMap = new HashMap(); for(PackageRelationship rel : wb.getRelationships()){ - if(rel.getRelationshipType().equals(XSSFRelation.WORKSHEET.getRelation())){ + if(rel.getRelationshipType().equals(XSSFRelation.WORKSHEET.getRelation()) || + rel.getRelationshipType().equals(XSSFRelation.CHARTSHEET.getRelation())){ PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI()); sheetMap.put(rel.getId(), wb.getPackage().getPart(relName)); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java index 0592fbcc76..11f03dd62d 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java @@ -116,4 +116,22 @@ public final class TestXSSFReader extends TestCase { } assertEquals(4, count); } + + + /** + * Iterating over a workbook with chart sheets in it, using the + * XSSFReader method + * @throws Exception + */ + public void test50119() throws Exception { + OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("WithChartSheet.xlsx"); + XSSFReader r = new XSSFReader(pkg); + XSSFReader.SheetIterator it = (XSSFReader.SheetIterator)r.getSheetsData(); + + while(it.hasNext()) + { + InputStream stream = it.next(); + stream.close(); + } + } } diff --git a/test-data/spreadsheet/WithChartSheet.xlsx b/test-data/spreadsheet/WithChartSheet.xlsx new file mode 100644 index 0000000000..8defbd6cc4 Binary files /dev/null and b/test-data/spreadsheet/WithChartSheet.xlsx differ