summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java6
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java18
-rw-r--r--test-data/spreadsheet/57925.xlsbin0 -> 69120 bytes
3 files changed, 23 insertions, 1 deletions
diff --git a/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java b/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
index ce918926ca..cc590772de 100644
--- a/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
+++ b/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
@@ -94,7 +94,11 @@ public final class OperationEvaluationContext {
if (externalSheet == null || externalSheet.getWorkbookName() == null) {
// sheet is in same workbook
targetEvaluator = _bookEvaluator;
- otherFirstSheetIndex = _workbook.getSheetIndex(externalSheet.getSheetName());
+ if(externalSheet == null) {
+ otherFirstSheetIndex = 0;
+ } else {
+ otherFirstSheetIndex = _workbook.getSheetIndex(externalSheet.getSheetName());
+ }
if (externalSheet instanceof ExternalSheetRange) {
String lastSheetName = ((ExternalSheetRange)externalSheet).getLastSheetName();
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
index f472e3d1d4..92661f8aee 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
@@ -2846,4 +2846,22 @@ public final class TestBugs extends BaseTestBugzillaIssues {
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();
+ }
}
diff --git a/test-data/spreadsheet/57925.xls b/test-data/spreadsheet/57925.xls
new file mode 100644
index 0000000000..ef13551ff4
--- /dev/null
+++ b/test-data/spreadsheet/57925.xls
Binary files differ