Bug 50119 - NullPointerException is throw in XSSFReader.SheetIterator.next() with a XLSX contains a chartsheet.
Summary: NullPointerException is throw in XSSFReader.SheetIterator.next() with a XLSX...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.7-dev
Hardware: PC Windows Server 2003
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-19 23:37 UTC by Wu, Fan
Modified: 2010-10-20 12:26 UTC (History)
0 users



Attachments
Patch to fix this issue. (1.28 KB, patch)
2010-10-20 01:21 UTC, Wu, Fan
Details | Diff
File contains worksheet and chartsheet. (29.62 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2010-10-20 11:45 UTC, Wu, Fan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wu, Fan 2010-10-19 23:37:37 UTC
I tried to traverse all the sheets in a xlsx file with this:

XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) reader.getSheetsData();
while (iter.hasNext())
{
    InputStream stream = iter.next();
}

When the xlsx file contains a chartsheet, a NullPointerException is thrown.

I noticed there is a kindof inconsistence in XSSFReader.SheetIterator.

In the constructor of XSSFReader.SheetIterator only WORKSHEETs are added to the sheetMap.

But in XSSFReader.SheetIterator.next(), it is like this:
public InputStream next() {
    ctSheet = sheetIterator.next();
    String sheetId = ctSheet.getId();
    try {
        // if we have sheetId of ChartSheet, we will get nullpointer exception.
	PackagePart sheetPkg = sheetMap.get(sheetId);
	return sheetPkg.getInputStream();
    } catch(IOException e) {
        throw new POIXMLException(e);
    }
}
Comment 1 Wu, Fan 2010-10-20 01:21:17 UTC
Created attachment 26185 [details]
Patch to fix this issue.
Comment 2 Nick Burch 2010-10-20 11:14:55 UTC
Could you please upload a .xlsx file that triggers the problem? I'd like to get a unit test in for this, and none of the current chart .xlsx files seem to trigger it
Comment 3 Wu, Fan 2010-10-20 11:45:28 UTC
Created attachment 26188 [details]
File contains worksheet and chartsheet.
Comment 4 Wu, Fan 2010-10-20 11:50:22 UTC
.xlsx file is attached.
(In reply to comment #2)
> Could you please upload a .xlsx file that triggers the problem? I'd like to get
> a unit test in for this, and none of the current chart .xlsx files seem to
> trigger it
Comment 5 Nick Burch 2010-10-20 12:26:11 UTC
Thanks, fixed in r1025630.