@@ -, +, @@ whether formulas are validated during XSSFCell.setCellFormula or not --- .../org/apache/poi/xssf/usermodel/XSSFCell.java | 8 +++++--- .../apache/poi/xssf/usermodel/XSSFWorkbook.java | 24 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -561,9 +561,11 @@ public final class XSSFCell implements Cell { return; } - XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb); - //validate through the FormulaParser - FormulaParser.parse(formula, fpb, formulaType, wb.getSheetIndex(getSheet()), getRowIndex()); + if(wb.getCellFormulaValidation()) { + XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb); + //validate through the FormulaParser + FormulaParser.parse(formula, fpb, formulaType, wb.getSheetIndex(getSheet()), getRowIndex()); + } CTCellFormula f = CTCellFormula.Factory.newInstance(); f.setStringValue(formula); --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -209,6 +209,11 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook { private MissingCellPolicy _missingCellPolicy = MissingCellPolicy.RETURN_NULL_AND_BLANK; /** + * Whether a call to {@link XSSFCell#setCellFormula(String)} will validate the formula or not. + */ + private boolean cellFormulaValidation = true; + + /** * array of pictures for this workbook */ private List pictures; @@ -2470,4 +2475,23 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook { return oleId; } + + /** + * Whether a call to {@link XSSFCell#setCellFormula(String)} will validate the formula or not. + * + * @param value true if the application will validate the formula is correct + * @since 3.17 + */ + public void setCellFormulaValidation(final boolean value) { + this.cellFormulaValidation = value; + } + + /** + * Whether a call to {@link XSSFCell#setCellFormula(String)} will validate the formula or not. + * + * @since 3.17 + */ + public boolean getCellFormulaValidation() { + return this.cellFormulaValidation; + } } --