use of org.apache.poi.ss.formula.IStabilityClassifier in project poi by apache.
the class TestForkedEvaluator method testBasic.
/**
* Shows a basic use-case for {@link ForkedEvaluator}
*/
@Test
public void testBasic() throws IOException {
Workbook wb = createWorkbook();
// The stability classifier is useful to reduce memory consumption of caching logic
IStabilityClassifier stabilityClassifier = new IStabilityClassifier() {
@Override
public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
return sheetIndex == 1;
}
};
ForkedEvaluator fe1 = ForkedEvaluator.create(wb, stabilityClassifier, null);
ForkedEvaluator fe2 = ForkedEvaluator.create(wb, stabilityClassifier, null);
// fe1 and fe2 can be used concurrently on separate threads
fe1.updateCell("Inputs", 0, 0, new NumberEval(4.0));
fe1.updateCell("Inputs", 0, 1, new NumberEval(1.1));
fe2.updateCell("Inputs", 0, 0, new NumberEval(1.2));
fe2.updateCell("Inputs", 0, 1, new NumberEval(2.0));
assertEquals(18.9, ((NumberEval) fe1.evaluate("Calculations", 0, 0)).getNumberValue(), 0.0);
assertEquals(4.0, ((NumberEval) fe2.evaluate("Calculations", 0, 0)).getNumberValue(), 0.0);
fe1.updateCell("Inputs", 0, 0, new NumberEval(3.0));
assertEquals(13.9, ((NumberEval) fe1.evaluate("Calculations", 0, 0)).getNumberValue(), 0.0);
wb.close();
}
use of org.apache.poi.ss.formula.IStabilityClassifier in project poi by apache.
the class TestDec2Bin method createContext.
private OperationEvaluationContext createContext() {
HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("13.43");
cell = row.createCell(1);
cell.setCellValue("8");
cell = row.createCell(2);
cell.setCellValue("-8");
cell = row.createCell(3);
cell.setCellValue("1");
HSSFEvaluationWorkbook workbook = HSSFEvaluationWorkbook.create(wb);
WorkbookEvaluator workbookEvaluator = new WorkbookEvaluator(workbook, new IStabilityClassifier() {
@Override
public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
return true;
}
}, null);
OperationEvaluationContext ctx = new OperationEvaluationContext(workbookEvaluator, workbook, 0, 0, 0, null);
return ctx;
}
use of org.apache.poi.ss.formula.IStabilityClassifier in project poi by apache.
the class TestBin2Dec method createContext.
private OperationEvaluationContext createContext() {
HSSFWorkbook wb = new HSSFWorkbook();
wb.createSheet();
HSSFEvaluationWorkbook workbook = HSSFEvaluationWorkbook.create(wb);
WorkbookEvaluator workbookEvaluator = new WorkbookEvaluator(workbook, new IStabilityClassifier() {
@Override
public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
return true;
}
}, null);
OperationEvaluationContext ctx = new OperationEvaluationContext(workbookEvaluator, workbook, 0, 0, 0, null);
return ctx;
}
use of org.apache.poi.ss.formula.IStabilityClassifier in project poi by apache.
the class TestHex2Dec method createContext.
private OperationEvaluationContext createContext() {
HSSFWorkbook wb = new HSSFWorkbook();
wb.createSheet();
HSSFEvaluationWorkbook workbook = HSSFEvaluationWorkbook.create(wb);
WorkbookEvaluator workbookEvaluator = new WorkbookEvaluator(workbook, new IStabilityClassifier() {
@Override
public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
return true;
}
}, null);
OperationEvaluationContext ctx = new OperationEvaluationContext(workbookEvaluator, workbook, 0, 0, 0, null);
return ctx;
}
use of org.apache.poi.ss.formula.IStabilityClassifier in project poi by apache.
the class TestDec2Hex method createContext.
private OperationEvaluationContext createContext() {
HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("123.43");
cell = row.createCell(1);
cell.setCellValue("8");
cell = row.createCell(2);
cell.setCellValue("-8");
HSSFEvaluationWorkbook workbook = HSSFEvaluationWorkbook.create(wb);
WorkbookEvaluator workbookEvaluator = new WorkbookEvaluator(workbook, new IStabilityClassifier() {
@Override
public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
return true;
}
}, null);
OperationEvaluationContext ctx = new OperationEvaluationContext(workbookEvaluator, workbook, 0, 0, 0, null);
return ctx;
}
Aggregations