aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml/src/main/java
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-11-02 18:59:18 +0000
committerPJ Fanning <fanningpj@apache.org>2021-11-02 18:59:18 +0000
commit1328893212c74d4bf41e408b04d28e0928a29d80 (patch)
tree487f50bf80e84176c2a567066cbe2ac35d45836f /poi-ooxml/src/main/java
parentd9b6f799a648d5b55401c2e4a41c60e99782abb1 (diff)
downloadpoi-1328893212c74d4bf41e408b04d28e0928a29d80.tar.gz
poi-1328893212c74d4bf41e408b04d28e0928a29d80.zip
[github-269] more work on external workbook links (formulas). Thanks to @aspojo. This closes #269
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894695 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src/main/java')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCreationHelper.java1
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java15
2 files changed, 15 insertions, 1 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCreationHelper.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCreationHelper.java
index d18177c032..4095bf78b7 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCreationHelper.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCreationHelper.java
@@ -61,6 +61,7 @@ public class SXSSFCreationHelper implements CreationHelper {
@Override
public SXSSFFormulaEvaluator createFormulaEvaluator() {
+
return new SXSSFFormulaEvaluator(wb);
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
index a1d33c9600..d7ed668d1f 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
@@ -29,6 +29,7 @@ import org.apache.poi.ss.formula.FormulaRenderer;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.SharedFormula;
import org.apache.poi.ss.formula.eval.ErrorEval;
+import org.apache.poi.ss.formula.ptg.ErrPtg;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellBase;
@@ -474,7 +475,19 @@ public final class XSSFCell extends CellBase {
if (wb.getCellFormulaValidation()) {
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
//validate through the FormulaParser
- FormulaParser.parse(formula, fpb, formulaType, wb.getSheetIndex(getSheet()), getRowIndex());
+ Ptg[] ptgs = FormulaParser.parse(formula, fpb, formulaType, wb.getSheetIndex(getSheet()), getRowIndex());
+ // Make its format consistent with Excel.
+ // eg: "SUM('Sheet1:Sheet2'!A1:B1)" will be trans to "SUM(Sheet1:Sheet2!A1:B1)"
+ boolean hasError = false;
+ for (Ptg ptg : ptgs) {
+ if (ptg instanceof ErrPtg) {
+ hasError = true;
+ break;
+ }
+ }
+ if (!hasError) {
+ formula = FormulaRenderer.toFormulaString(fpb, ptgs);
+ }
}
CTCellFormula f;