aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/EventWorkbookBuilder.java9
-rw-r--r--src/java/org/apache/poi/ss/formula/ptg/ExternSheetNameResolver.java11
2 files changed, 16 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/EventWorkbookBuilder.java b/src/java/org/apache/poi/hssf/eventusermodel/EventWorkbookBuilder.java
index c6036d6582..b0d0388a2c 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/EventWorkbookBuilder.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/EventWorkbookBuilder.java
@@ -138,7 +138,14 @@ public class EventWorkbookBuilder {
}
public HSSFWorkbook getStubHSSFWorkbook() {
- return HSSFWorkbook.create(getStubWorkbook());
+ // Create a base workbook
+ HSSFWorkbook wb = HSSFWorkbook.create(getStubWorkbook());
+ // Stub the sheets, so sheet name lookups work
+ for (BoundSheetRecord bsr : boundSheetRecords) {
+ wb.createSheet(bsr.getSheetname());
+ }
+ // Ready for Formula use!
+ return wb;
}
public InternalWorkbook getStubWorkbook() {
return createStubWorkbook(
diff --git a/src/java/org/apache/poi/ss/formula/ptg/ExternSheetNameResolver.java b/src/java/org/apache/poi/ss/formula/ptg/ExternSheetNameResolver.java
index 150bd99e79..be20167ed9 100644
--- a/src/java/org/apache/poi/ss/formula/ptg/ExternSheetNameResolver.java
+++ b/src/java/org/apache/poi/ss/formula/ptg/ExternSheetNameResolver.java
@@ -17,8 +17,8 @@
package org.apache.poi.ss.formula.ptg;
-import org.apache.poi.ss.formula.FormulaRenderingWorkbook;
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheet;
+import org.apache.poi.ss.formula.FormulaRenderingWorkbook;
import org.apache.poi.ss.formula.SheetNameFormatter;
/**
@@ -36,8 +36,13 @@ final class ExternSheetNameResolver {
if (externalSheet != null) {
String wbName = externalSheet.getWorkbookName();
String sheetName = externalSheet.getSheetName();
- sb = new StringBuffer(wbName.length() + sheetName.length() + cellRefText.length() + 4);
- SheetNameFormatter.appendFormat(sb, wbName, sheetName);
+ if (wbName != null) {
+ sb = new StringBuffer(wbName.length() + sheetName.length() + cellRefText.length() + 4);
+ SheetNameFormatter.appendFormat(sb, wbName, sheetName);
+ } else {
+ sb = new StringBuffer(sheetName.length() + cellRefText.length() + 4);
+ SheetNameFormatter.appendFormat(sb, sheetName);
+ }
} else {
String sheetName = book.getSheetNameByExternSheet(field_1_index_extern_sheet);
sb = new StringBuffer(sheetName.length() + cellRefText.length() + 4);