Class AbstractFormulaProcessor

java.lang.Object
org.jxls.formula.AbstractFormulaProcessor
All Implemented Interfaces:
FormulaProcessor
Direct Known Subclasses:
FastFormulaProcessor, StandardFormulaProcessor

public abstract class AbstractFormulaProcessor extends Object implements FormulaProcessor
Partial implementation of FormulaProcessor interface It implements only some helper methods to allow their reuse for FastFormulaProcessor and StandardFormulaProcessor
  • Field Details

  • Constructor Details

    • AbstractFormulaProcessor

      public AbstractFormulaProcessor()
  • Method Details

    • buildTargetCellRefMap

      protected Map<CellRef,List<CellRef>> buildTargetCellRefMap(Transformer transformer, Area area, CellData formulaCellData)
    • buildJointedCellRefMap

      protected Map<String,List<CellRef>> buildJointedCellRefMap(Transformer transformer, CellData formulaCellData)
    • getCellRefsFromJointedCellRef

      protected List<String> getCellRefsFromJointedCellRef(String jointedCellRef)
      Parses a "jointed cell" reference and extracts individual cell references
      Parameters:
      jointedCellRef - a jointed cell reference to parse
      Returns:
      a list of cell names extracted from the jointed cell reference
    • getFormulaCellRefs

      public static List<String> getFormulaCellRefs(String formula)
      Parses a formula and returns a list of cell names used in it E.g. for formula "B4*(1+C4)" the returned list will contain "B4", "C4"
      Parameters:
      formula - string
      Returns:
      a list of cell names used in the formula
    • getJointedCellRefs

      protected List<String> getJointedCellRefs(String formula)
      Parses a formula to extract a list of so called "jointed cells" The jointed cells are cells combined with a special notation "U_(cell1, cell2)" into a single cell They are used in formulas like this "$[SUM(U_(F8,F13))]". Here the formula will use both F8 and F13 source cells to calculate the sum
      Parameters:
      formula - a formula string to parse
      Returns:
      a list of jointed cells used in the formula
    • groupByRanges

      protected List<List<CellRef>> groupByRanges(List<CellRef> cellRefList, int targetRangeCount)
      Groups a list of cell references into a list ranges which can be used in a formula substitution
      Parameters:
      cellRefList - a list of cell references
      targetRangeCount - a number of ranges to use when grouping
      Returns:
      a list of cell ranges grouped by row or by column
    • groupByColRange

      protected List<List<CellRef>> groupByColRange(List<CellRef> cellRefList)
      Groups a list of cell references in a column into a list of ranges
      Parameters:
      cellRefList - -
      Returns:
      a list of cell reference groups
    • groupByRowRange

      protected List<List<CellRef>> groupByRowRange(List<CellRef> cellRefList)
      Groups a list of cell references in a row into a list of ranges
      Parameters:
      cellRefList - -
      Returns:
      -
    • sheetNameRegex

      protected String sheetNameRegex(Map.Entry<CellRef,List<CellRef>> cellRefEntry)
      Parameters:
      cellRefEntry - -
      Returns:
      the sheet name regular expression string
    • createTargetCellRefListByColumn

      protected List<CellRef> createTargetCellRefListByColumn(CellRef targetFormulaCellRef, List<CellRef> targetCells, List<CellRef> cellRefsToExclude)
      Creates a list of target formula cell references
      Parameters:
      targetFormulaCellRef - -
      targetCells - -
      cellRefsToExclude - -
      Returns:
      -
    • processTargetFormulaCells

      protected void processTargetFormulaCells(CellData formulaCellData, Transformer transformer, Area area)
    • processTargetFormulaCell

      protected abstract void processTargetFormulaCell(int i, CellData formulaCellData, org.jxls.formula.AbstractFormulaProcessor.FormulaProcessorContext fpc)
    • createFormulaProcessorContext

      protected org.jxls.formula.AbstractFormulaProcessor.FormulaProcessorContext createFormulaProcessorContext(CellData formulaCellData, Transformer transformer, Area area)
    • processTargetFormula

      protected void processTargetFormula(CellData formulaCellData, org.jxls.formula.AbstractFormulaProcessor.FormulaProcessorContext fpc)