use of org.apache.poi.ss.usermodel.CellType in project poi by apache.
the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_Blank.
@Test
public void testIFEqualsFormulaEvaluation_Blank() {
final String formula = "IF(A1=1, B1, C1)";
final CellType cellType = CellType.BLANK;
final String expectedFormula = "IF(A1=1,B1,C1)";
final double expectedValue = 3.0;
testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
use of org.apache.poi.ss.usermodel.CellType in project poi by apache.
the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_BooleanSimple.
@Ignore("Bug 58591: this test currently fails")
@Test
public void testIFEqualsFormulaEvaluation_BooleanSimple() {
final String formula = "3-(A1=1)";
final CellType cellType = CellType.BOOLEAN;
final String expectedFormula = "3-(A1=1)";
final double expectedValue = 2.0;
testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
use of org.apache.poi.ss.usermodel.CellType in project poi by apache.
the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_Formula.
@Test
public void testIFEqualsFormulaEvaluation_Formula() {
final String formula = "IF(A1=1, B1, C1)";
final CellType cellType = CellType.FORMULA;
final String expectedFormula = "IF(A1=1,B1,C1)";
final double expectedValue = 2.0;
testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
use of org.apache.poi.ss.usermodel.CellType in project poi by apache.
the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_evaluateFormulaCell.
private void testIFEqualsFormulaEvaluation_evaluateFormulaCell(String formula, CellType cellType, String expectedFormula, double expectedResult) {
Workbook wb = testIFEqualsFormulaEvaluation_setup(formula, cellType);
Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
CellType resultCellType = eval.evaluateFormulaCellEnum(D1);
// Call should modify the contents, but leave the formula intact
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
assertEquals(expectedFormula, D1.getCellFormula());
assertEquals(CellType.NUMERIC, resultCellType);
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum());
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
testIFEqualsFormulaEvaluation_teardown(wb);
}
use of org.apache.poi.ss.usermodel.CellType in project poi by apache.
the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_StringCompareToString.
@Test
public void testIFEqualsFormulaEvaluation_StringCompareToString() {
final String formula = "IF(A1=\"1\", B1, C1)";
final CellType cellType = CellType.STRING;
final String expectedFormula = "IF(A1=\"1\",B1,C1)";
final double expectedValue = 2.0;
testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
Aggregations