| java.lang.Object org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator
HSSFFormulaEvaluator | public class HSSFFormulaEvaluator (Code) | | author: Amol S. Deshmukh < amolweb at ya hoo dot com > author: Limitations: Unfortunately, cyclic references will cause stackoverflow author: exception |
Inner Class :final public static class CellValue | |
Method Summary | |
public CellValue | evaluate(HSSFCell cell) If cell contains a formula, the formula is evaluated and returned,
else the CellValue simply copies the appropriate cell value from
the cell and also its cell type. | public HSSFCell | evaluateInCell(HSSFCell cell) If cell contains formula, it evaluates the formula, and puts the
formula result back into the cell.
Else if cell does not contain formula, this method leaves the cell
unchanged. | protected static CellValue | getCellValueForEval(ValueEval eval) Returns a CellValue wrapper around the supplied ValueEval instance. | protected static ValueEval | getEvalForCell(HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook) Given a cell, find its type and from that create an appropriate ValueEval
impl instance and return that. | protected static Eval | getEvalForPtg(Ptg ptg) returns an appropriate Eval impl instance for the Ptg. | protected static Eval | getOperationEvalForPtg(OperationPtg ptg) | public static FormulaParser | getUnderlyingParser(HSSFWorkbook workbook, String formula) Returns an underlying FormulaParser, for the specified
Formula String and HSSFWorkbook.
This will allow you to generate the Ptgs yourself, if
your needs are more complex than just having the
formula evaluated. | void | inspectPtgs(String formula) | protected static ValueEval | internalEvaluate(HSSFCell srcCell, HSSFRow srcRow, HSSFSheet sheet, HSSFWorkbook workbook) Dev. | protected static void | pushRef2DEval(ReferencePtg ptg, Stack stack, HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook) create a Ref2DEval for ReferencePtg and push it on the stack. | protected static void | pushRef3DEval(Ref3DPtg ptg, Stack stack, HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook) create a Ref3DEval for Ref3DPtg and push it on the stack. | public void | setCurrentRow(HSSFRow row) |
evaluate | public CellValue evaluate(HSSFCell cell)(Code) | | If cell contains a formula, the formula is evaluated and returned,
else the CellValue simply copies the appropriate cell value from
the cell and also its cell type. This method should be preferred over
evaluateInCell() when the call should not modify the contents of the
original cell.
Parameters: cell - |
evaluateInCell | public HSSFCell evaluateInCell(HSSFCell cell)(Code) | | If cell contains formula, it evaluates the formula, and puts the
formula result back into the cell.
Else if cell does not contain formula, this method leaves the cell
unchanged. Note that the same instance of HSSFCell is returned to
allow chained calls like:
int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType();
Parameters: cell - |
getCellValueForEval | protected static CellValue getCellValueForEval(ValueEval eval)(Code) | | Returns a CellValue wrapper around the supplied ValueEval instance.
Parameters: eval - |
getEvalForCell | protected static ValueEval getEvalForCell(HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook)(Code) | | Given a cell, find its type and from that create an appropriate ValueEval
impl instance and return that. Since the cell could be an external
reference, we need the sheet that this belongs to.
Non existent cells are treated as empty.
Parameters: cell - Parameters: sheet - Parameters: workbook - |
getEvalForPtg | protected static Eval getEvalForPtg(Ptg ptg)(Code) | | returns an appropriate Eval impl instance for the Ptg. The Ptg must be
one of: Area3DPtg, AreaPtg, ReferencePtg, Ref3DPtg, IntPtg, NumberPtg,
StringPtg, BoolPtg special Note: OperationPtg subtypes cannot be
passed here!
Parameters: ptg - |
getOperationEvalForPtg | protected static Eval getOperationEvalForPtg(OperationPtg ptg)(Code) | | returns the OperationEval concrete impl instance corresponding
to the suplied operationPtg
Parameters: ptg - |
getUnderlyingParser | public static FormulaParser getUnderlyingParser(HSSFWorkbook workbook, String formula)(Code) | | Returns an underlying FormulaParser, for the specified
Formula String and HSSFWorkbook.
This will allow you to generate the Ptgs yourself, if
your needs are more complex than just having the
formula evaluated.
|
inspectPtgs | void inspectPtgs(String formula)(Code) | | debug method
Parameters: formula - Parameters: sheet - Parameters: workbook - |
internalEvaluate | protected static ValueEval internalEvaluate(HSSFCell srcCell, HSSFRow srcRow, HSSFSheet sheet, HSSFWorkbook workbook)(Code) | | Dev. Note: Internal evaluate must be passed only a formula cell
else a runtime exception will be thrown somewhere inside the method.
(Hence this is a private method.)
Parameters: srcCell - Parameters: srcRow - Parameters: sheet - Parameters: workbook - |
pushRef2DEval | protected static void pushRef2DEval(ReferencePtg ptg, Stack stack, HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook)(Code) | | create a Ref2DEval for ReferencePtg and push it on the stack.
Non existent cells are treated as RefEvals containing BlankEval.
Parameters: ptg - Parameters: stack - Parameters: cell - Parameters: sheet - Parameters: workbook - |
pushRef3DEval | protected static void pushRef3DEval(Ref3DPtg ptg, Stack stack, HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook)(Code) | | create a Ref3DEval for Ref3DPtg and push it on the stack.
Parameters: ptg - Parameters: stack - Parameters: cell - Parameters: sheet - Parameters: workbook - |
|
|