Fix bug #50119 - avoid NPE when XSSFReader comes across chart sheets

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1025630 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2010-10-20 16:25:24 +00:00
parent d2d0c131c0
commit 26b76c1087
4 changed files with 21 additions and 2 deletions

View File

@ -34,7 +34,7 @@
<changes>
<release version="3.8-beta1" date="2010-??-??">
<action dev="poi-developers" type="fix">50119 - avoid NPE when XSSFReader comes across chart sheets</action>
</release>
<release version="3.7" date="2010-10-25">
<action dev="poi-developers" type="fix">50075 - avoid NPE in ListLevel.getNumberText() when numberText is null </action>

View File

@ -177,7 +177,8 @@ public class XSSFReader {
//step 1. Map sheet's relationship Id and the corresponding PackagePart
sheetMap = new HashMap<String, PackagePart>();
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));
}

View File

@ -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();
}
}
}

Binary file not shown.