Bug 57925: Add unit test and a simple fix to at least avoid the NPE when Workbooks have invalid external references
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1703999 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3a325dc5dc
commit
a207e463e9
@ -94,7 +94,11 @@ public final class OperationEvaluationContext {
|
|||||||
if (externalSheet == null || externalSheet.getWorkbookName() == null) {
|
if (externalSheet == null || externalSheet.getWorkbookName() == null) {
|
||||||
// sheet is in same workbook
|
// sheet is in same workbook
|
||||||
targetEvaluator = _bookEvaluator;
|
targetEvaluator = _bookEvaluator;
|
||||||
otherFirstSheetIndex = _workbook.getSheetIndex(externalSheet.getSheetName());
|
if(externalSheet == null) {
|
||||||
|
otherFirstSheetIndex = 0;
|
||||||
|
} else {
|
||||||
|
otherFirstSheetIndex = _workbook.getSheetIndex(externalSheet.getSheetName());
|
||||||
|
}
|
||||||
|
|
||||||
if (externalSheet instanceof ExternalSheetRange) {
|
if (externalSheet instanceof ExternalSheetRange) {
|
||||||
String lastSheetName = ((ExternalSheetRange)externalSheet).getLastSheetName();
|
String lastSheetName = ((ExternalSheetRange)externalSheet).getLastSheetName();
|
||||||
|
@ -2846,4 +2846,22 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test57925() throws IOException {
|
||||||
|
Workbook wb = HSSFTestDataSamples.openSampleWorkbook("57925.xls");
|
||||||
|
|
||||||
|
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
||||||
|
|
||||||
|
for(int i = 0;i < wb.getNumberOfSheets();i++) {
|
||||||
|
Sheet sheet = wb.getSheetAt(i);
|
||||||
|
for(Row row : sheet) {
|
||||||
|
for(Cell cell : row) {
|
||||||
|
new DataFormatter().formatCellValue(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wb.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
test-data/spreadsheet/57925.xls
Normal file
BIN
test-data/spreadsheet/57925.xls
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user