use of org.apache.poi.ss.usermodel.CellValue in project poi by apache.
the class TestDate method confirm.
private void confirm(String formulaText, double expectedResult) {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
}
double actualValue = cv.getNumberValue();
assertEquals(expectedResult, actualValue, 0);
}
use of org.apache.poi.ss.usermodel.CellValue in project poi by apache.
the class TestCalendarFieldFunction method confirm.
private void confirm(String formulaText, double expectedResult) {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
}
double actualValue = cv.getNumberValue();
assertEquals(expectedResult, actualValue, 0);
}
use of org.apache.poi.ss.usermodel.CellValue in project chilo-producer by cccties.
the class ExcelReader method getStringFormulaValue.
public String getStringFormulaValue(Cell cell) {
assert cell.getCellType() == Cell.CELL_TYPE_FORMULA;
CreationHelper helper = workBook.getCreationHelper();
FormulaEvaluator evaluator = helper.createFormulaEvaluator();
CellValue value = evaluator.evaluate(cell);
switch(value.getCellType()) {
case Cell.CELL_TYPE_STRING:
return value.getStringValue();
case Cell.CELL_TYPE_NUMERIC:
return Double.toString(value.getNumberValue());
case Cell.CELL_TYPE_BOOLEAN:
return Boolean.toString(value.getBooleanValue());
default:
System.out.println(value.getCellType());
return null;
}
}
Aggregations