List of usage examples for org.apache.poi.ss.usermodel CellValue CellValue
public CellValue(String stringValue)
From source file:com.miraisolutions.xlconnect.data.ColumnBuilder.java
License:Open Source License
protected CellValue getCachedCellValue(Cell cell) { int valueType = cell.getCellType(); if (valueType == Cell.CELL_TYPE_FORMULA) { valueType = cell.getCachedFormulaResultType(); }//from ww w . ja v a 2s. c om switch (valueType) { case Cell.CELL_TYPE_BLANK: return null; case Cell.CELL_TYPE_BOOLEAN: if (cell.getBooleanCellValue()) { return CellValue.TRUE; } else { return CellValue.FALSE; } case Cell.CELL_TYPE_NUMERIC: return new CellValue(cell.getNumericCellValue()); case Cell.CELL_TYPE_STRING: return new CellValue(cell.getStringCellValue()); case Cell.CELL_TYPE_ERROR: return CellValue.getError(cell.getErrorCellValue()); default: String msg = String.format("Could not extract value from cell with cached value type %d", valueType); throw new RuntimeException(msg); } }
From source file:hu.webhejj.commons.io.table.excel.ExcelRowValueConverter.java
License:Apache License
private CellValue getCellValue(Row row, Cell cell, int column) { CellValue cellValue = null;/*from w w w. jav a2 s . co m*/ try { cellValue = evaluator.evaluate(cell); } catch (RuntimeException e) { if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) { switch (cell.getCachedFormulaResultType()) { case Cell.CELL_TYPE_NUMERIC: cellValue = new CellValue(cell.getNumericCellValue()); break; case Cell.CELL_TYPE_STRING: cellValue = new CellValue(cell.getStringCellValue()); break; default: System.err.format(" Cell[%d,%d] unknown cached formula type %s\n", row.getRowNum(), column, cell.getCachedFormulaResultType()); } } } return cellValue; }