Class ForkedEvaluator
java.lang.Object
org.apache.poi.ss.formula.eval.forked.ForkedEvaluator
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 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).-
Method Summary
Modifier and TypeMethodDescriptionvoidcopyUpdatedCells(Workbook workbook) Copies the values of all updated cells (modified by calls toupdateCell(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.static ForkedEvaluatorcreate(Workbook wb, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) 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.static voidsetupEnvironment(String[] workbookNames, ForkedEvaluator[] evaluators) Coordinates several formula evaluators together so that formulas that involve external references can be evaluated.voidupdateCell(String sheetName, int rowIndex, int columnIndex, ValueEval value) Sets the specified cell to the supplied value
-
Method Details
-
create
public static ForkedEvaluator create(Workbook wb, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) - Parameters:
udfFinder- passnullfor default (AnalysisToolPak only)
-
updateCell
Sets the specified cell to the supplied value- Parameters:
sheetName- the name of the sheet containing the cellrowIndex- zero basedcolumnIndex- zero based
-
copyUpdatedCells
Copies the values of all updated cells (modified by calls toupdateCell(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. -
evaluate
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- the name of the sheet containing the cellrowIndex- zero basedcolumnIndex- zero based- Returns:
nullif the supplied cell isnullor blank
-
setupEnvironment
Coordinates several formula evaluators together so that formulas that involve external references can be evaluated.- Parameters:
workbookNames- 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- all evaluators for the full set of workbooks required by the formulas.
-