Package org.apache.poi.xssf.usermodel
Class XSSFFormulaEvaluator
java.lang.Object
org.apache.poi.ss.formula.BaseFormulaEvaluator
org.apache.poi.xssf.usermodel.BaseXSSFFormulaEvaluator
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator
- All Implemented Interfaces:
WorkbookEvaluatorProvider,FormulaEvaluator
Evaluates formula cells.
For performance reasons, this class keeps a cache of all previously calculated intermediate
cell values. Be sure to call BaseFormulaEvaluator.clearAllCachedResultValues() if any workbook cells are changed between
calls to evaluate~ methods on this class.
-
Field Summary
Fields inherited from class org.apache.poi.ss.formula.BaseFormulaEvaluator
_bookEvaluator -
Constructor Summary
ConstructorsModifierConstructorDescriptionXSSFFormulaEvaluator(XSSFWorkbook workbook) protectedXSSFFormulaEvaluator(XSSFWorkbook workbook, WorkbookEvaluator bookEvaluator) -
Method Summary
Modifier and TypeMethodDescriptionstatic XSSFFormulaEvaluatorcreate(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) voidLoops over all cells in all sheets of the supplied workbook.static voidLoops over all cells in all sheets of the supplied workbook.evaluateInCell(Cell cell) If cell contains formula, it evaluates the formula, and puts the formula result back into the cell, in place of the old formula.voidnotifyDeleteCell(Cell cell) Should be called to tell the cell value cache that the specified cell has just become a formula cell, or the formula text has changedvoidnotifySetFormula(Cell cell) Should be called to tell the cell value cache that the specified (value or formula) cell has changed.voidnotifyUpdateCell(Cell cell) Should be called to tell the cell value cache that the specified (value or formula) cell has changed.protected EvaluationCelltoEvaluationCell(Cell cell) Turns a XSSFCell into a XSSFEvaluationCellMethods inherited from class org.apache.poi.xssf.usermodel.BaseXSSFFormulaEvaluator
createRichTextString, evaluateFormulaCellValue, setCellTypeMethods inherited from class org.apache.poi.ss.formula.BaseFormulaEvaluator
_getWorkbookEvaluator, clearAllCachedResultValues, evaluate, evaluateAllFormulaCells, evaluateAllFormulaCells, evaluateFormulaCell, evaluateFormulaCellEnum, getEvaluationWorkbook, setCellType, setCellValue, setDebugEvaluationOutputForNextEval, setIgnoreMissingWorkbooks, setupEnvironment, setupReferencedWorkbooks
-
Constructor Details
-
XSSFFormulaEvaluator
-
XSSFFormulaEvaluator
-
-
Method Details
-
create
public static XSSFFormulaEvaluator create(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) - Parameters:
stabilityClassifier- used to optimise caching performance. Passnullfor the (conservative) assumption that any cell may have its definition changed after evaluation begins.udfFinder- passnullfor default (AnalysisToolPak only)
-
notifySetFormula
Description copied from interface:FormulaEvaluatorShould be called to tell the cell value cache that the specified (value or formula) cell has changed. Failure to call this method after changing cell values will cause incorrect behaviour of the evaluate~ methods of this class -
notifyDeleteCell
Description copied from interface:FormulaEvaluatorShould be called to tell the cell value cache that the specified cell has just become a formula cell, or the formula text has changed -
notifyUpdateCell
Description copied from interface:FormulaEvaluatorShould be called to tell the cell value cache that the specified (value or formula) cell has changed. Failure to call this method after changing cell values will cause incorrect behaviour of the evaluate~ methods of this class -
evaluateAllFormulaCells
Loops over all cells in all sheets of the supplied workbook. For cells that contain formulas, their formulas are evaluated, and the results are saved. These cells remain as formula cells. For cells that do not contain formulas, no changes are made. This is a helpful wrapper around looping over all cells, and calling evaluateFormulaCell on each one. -
evaluateInCell
Description copied from class:BaseFormulaEvaluatorIf cell contains formula, it evaluates the formula, and puts the formula result back into the cell, in place of the old formula. Else if cell does not contain formula, this method leaves the cell unchanged. Note that the same instance ofCellis returned to allow chained calls like:int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType();
Be aware that your cell value will be changed to hold the result of the formula. If you simply want the formula value computed for you, useBaseFormulaEvaluator.evaluateFormulaCell(Cell)}- Specified by:
evaluateInCellin interfaceFormulaEvaluator- Overrides:
evaluateInCellin classBaseFormulaEvaluator- Parameters:
cell- TheCellto evaluate and modify.- Returns:
- the
cellthat was passed in, allowing for chained calls
-
evaluateAll
public void evaluateAll()Loops over all cells in all sheets of the supplied workbook. For cells that contain formulas, their formulas are evaluated, and the results are saved. These cells remain as formula cells. For cells that do not contain formulas, no changes are made. This is a helpful wrapper around looping over all cells, and calling evaluateFormulaCell on each one. -
toEvaluationCell
Turns a XSSFCell into a XSSFEvaluationCell- Specified by:
toEvaluationCellin classBaseXSSFFormulaEvaluator
-