Add XSSFWorkbook.setCellFormulaValidation to control whether formulas are validated during XSSFCell.setCellFormula or not
This commit is contained in:
parent
f10fa7ac69
commit
34fe9a15df
@ -561,9 +561,11 @@ public final class XSSFCell implements Cell {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(wb.getCellFormulaValidation()) {
|
||||||
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
|
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
|
||||||
//validate through the FormulaParser
|
//validate through the FormulaParser
|
||||||
FormulaParser.parse(formula, fpb, formulaType, wb.getSheetIndex(getSheet()), getRowIndex());
|
FormulaParser.parse(formula, fpb, formulaType, wb.getSheetIndex(getSheet()), getRowIndex());
|
||||||
|
}
|
||||||
|
|
||||||
CTCellFormula f = CTCellFormula.Factory.newInstance();
|
CTCellFormula f = CTCellFormula.Factory.newInstance();
|
||||||
f.setStringValue(formula);
|
f.setStringValue(formula);
|
||||||
|
@ -208,6 +208,11 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
|
|||||||
*/
|
*/
|
||||||
private MissingCellPolicy _missingCellPolicy = MissingCellPolicy.RETURN_NULL_AND_BLANK;
|
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
|
* array of pictures for this workbook
|
||||||
*/
|
*/
|
||||||
@ -2470,4 +2475,23 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
|
|||||||
|
|
||||||
return oleId;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user