diff options
Diffstat (limited to 'poi-ooxml/src/main/java')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCreationHelper.java | 1 | ||||
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java | 15 |
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; |