List of usage examples for org.apache.poi.xssf.usermodel XSSFFormulaEvaluator evaluate
@Override
public CellValue evaluate(Cell cell)
From source file:org.tridas.io.formats.ooxml.OOXMLReader.java
License:Apache License
private Double getCellValueAsDouble(Cell cell) { if (cell.getCellType() == Cell.CELL_TYPE_BLANK) { return null; } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { return null; } else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) { return null; } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) { try {//from w w w.j av a2s .c om XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator((XSSFWorkbook) wb); return evaluator.evaluate(cell).getNumberValue(); } catch (Exception e) { return null; } } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { return cell.getNumericCellValue(); } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) { try { Double dbl = Double.valueOf(cell.getStringCellValue()); return dbl; } catch (NumberFormatException e) { return null; } } return null; }