Bug 57163: Fix possible NullPointerException when a spreadsheet has no LinkTable and we try to adjust it during sheet removal.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1673168 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
570819e4f6
commit
12c220121e
@ -774,13 +774,14 @@ public final class InternalWorkbook {
|
||||
}
|
||||
}
|
||||
|
||||
if (linkTable != null) {
|
||||
// also tell the LinkTable about the removed sheet
|
||||
// +1 because we already removed it from the count of sheets!
|
||||
for(int i = sheetIndex+1;i < getNumSheets()+1;i++) {
|
||||
// also update the link-table as otherwise references might point at invalid sheets
|
||||
linkTable.removeSheet(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* make the tabid record look like the current situation.
|
||||
|
@ -2716,4 +2716,14 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
Workbook wb = openSample("57456.xls");
|
||||
wb.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test57163() throws IOException {
|
||||
Workbook wb = openSample("57163.xls");
|
||||
|
||||
while (wb.getNumberOfSheets() > 1) {
|
||||
wb.removeSheetAt(1);
|
||||
}
|
||||
wb.close();
|
||||
}
|
||||
}
|
||||
|
BIN
test-data/spreadsheet/57163.xls
Normal file
BIN
test-data/spreadsheet/57163.xls
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user