Class XSSFFormulaEvaluator

    • Constructor Detail

      • XSSFFormulaEvaluator

        public XSSFFormulaEvaluator​(XSSFWorkbook workbook)
    • Method Detail

      • create

        public static XSSFFormulaEvaluator create​(XSSFWorkbook workbook,
                                                  IStabilityClassifier stabilityClassifier,
                                                  UDFFinder udfFinder)
        Parameters:
        stabilityClassifier - used to optimise caching performance. Pass null for the (conservative) assumption that any cell may have its definition changed after evaluation begins.
        udfFinder - pass null for default (AnalysisToolPak only)
      • notifySetFormula

        public void notifySetFormula​(Cell cell)
        Description copied from interface: FormulaEvaluator
        Should 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

        public void notifyDeleteCell​(Cell cell)
        Description copied from interface: FormulaEvaluator
        Should 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

        public void notifyUpdateCell​(Cell cell)
        Description copied from interface: FormulaEvaluator
        Should 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

        public static void evaluateAllFormulaCells​(XSSFWorkbook wb)
        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

        public XSSFCell evaluateInCell​(Cell cell)
        Description copied from class: BaseFormulaEvaluator
        If 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 of Cell is 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, use BaseFormulaEvaluator.evaluateFormulaCell(Cell)}
        Specified by:
        evaluateInCell in interface FormulaEvaluator
        Overrides:
        evaluateInCell in class BaseFormulaEvaluator
        Parameters:
        cell - The Cell to evaluate and modify.
        Returns:
        the cell that 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.