Top Description Fields Constructors Methods
org.apache.poi.ss.formula.eval.forked

public final Class ForkedEvaluator

extends Object
Class Inheritance
Imports
java.util.stream.Stream, org.apache.poi.hssf.usermodel.HSSFWorkbook, org.apache.poi.ss.formula.CollaboratingWorkbooksEnvironment, .EvaluationCell, .EvaluationWorkbook, .IStabilityClassifier, .WorkbookEvaluator, org.apache.poi.ss.formula.eval.BoolEval, .ErrorEval, .NumberEval, .StringEval, .ValueEval, org.apache.poi.ss.formula.udf.UDFFinder, org.apache.poi.ss.usermodel.Workbook

An alternative workbook evaluator that saves memory in situations where a single workbook is concurrently and independently evaluated many times. With standard formula evaluation, around 90% of memory consumption is due to loading of the HSSFWorkbook or org.apache.poi.xssf.usermodel.XSSFWorkbook. This class enables a 'master workbook' to be loaded just once and shared between many evaluation clients. Each evaluation client creates its own ForkedEvaluator and can set cell values that will be used for local evaluations (and don't disturb evaluations on other evaluators).

Field Summary

Modifier and TypeField and Description
private final WorkbookEvaluator
private final ForkedEvaluationWorkbook

Constructor Summary

AccessConstructor and Description
private
ForkedEvaluator(EvaluationWorkbook masterWorkbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)

Method Summary

Modifier and TypeMethod and Description
public void
copyUpdatedCells(Workbook workbook)

Copies the values of all updated cells (modified by calls to updateCell(String, int, int, ValueEval)) to the supplied workbook.

public static ForkedEvaluator
create(Workbook wb, IStabilityClassifier stabilityClassifier, UDFFinder
pass null for default (AnalysisToolPak only)
udfFinder
)

public ValueEval

Returns:

null if the supplied cell is null or blank
evaluate
(String
the name of the sheet containing the cell
sheetName
,
int
zero based
rowIndex
,
int
zero based
columnIndex
)

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 static void
setupEnvironment(String[]
the simple file names used to identify the workbooks in formulas with external links (for example "MyData.xls" as used in a formula "[MyData.xls]Sheet1!A1")
workbookNames
,
ForkedEvaluator[]
all evaluators for the full set of workbooks required by the formulas.
evaluators
)

Coordinates several formula evaluators together so that formulas that involve external references can be evaluated.

public void
updateCell(String
the name of the sheet containing the cell
sheetName
,
int
zero based
rowIndex
,
int
zero based
columnIndex
,
ValueEval value)

Sets the specified cell to the supplied value

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_evaluatorback to summary
private final WorkbookEvaluator _evaluator
_sewbback to summary
private final ForkedEvaluationWorkbook _sewb

Constructor Detail

ForkedEvaluatorback to summary
private ForkedEvaluator(EvaluationWorkbook masterWorkbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)

Method Detail

copyUpdatedCellsback to summary
public void copyUpdatedCells(Workbook workbook)

Copies the values of all updated cells (modified by calls to updateCell(String, int, int, ValueEval)) to the supplied workbook.
Typically, the supplied workbook is a writable copy of the 'master workbook', but at the very least it must contain sheets with the same names.

createback to summary
public static ForkedEvaluator create(Workbook wb, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
Parameters
udfFinder:UDFFinder

pass null for default (AnalysisToolPak only)

evaluateback to summary
public ValueEval evaluate(String sheetName, int rowIndex, int columnIndex)

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
sheetName:String

the name of the sheet containing the cell

rowIndex:int

zero based

columnIndex:int

zero based

Returns:ValueEval

null if the supplied cell is null or blank

setupEnvironmentback to summary
public static void setupEnvironment(String[] workbookNames, ForkedEvaluator[] evaluators)

Coordinates several formula evaluators together so that formulas that involve external references can be evaluated.

Parameters
workbookNames:String[]

the simple file names used to identify the workbooks in formulas with external links (for example "MyData.xls" as used in a formula "[MyData.xls]Sheet1!A1")

evaluators:ForkedEvaluator[]

all evaluators for the full set of workbooks required by the formulas.

updateCellback to summary
public void updateCell(String sheetName, int rowIndex, int columnIndex, ValueEval value)

Sets the specified cell to the supplied value

Parameters
sheetName:String

the name of the sheet containing the cell

rowIndex:int

zero based

columnIndex:int

zero based