@Override public CellType evaluateFormulaCell(Cell cell) { return cell.getCachedFormulaResultType(); } /**
/** * Note that this assumes the cell cached value is up to date and in sync with data edits * * @param cell The {@link Cell} to check. * @param type The {@link CellType} to check for. * @return true if the cell or cached cell formula result type match the given type */ public static boolean isType(Cell cell, CellType type) { final CellType cellType = cell.getCellType(); return cellType == type || (cellType == CellType.FORMULA && cell.getCachedFormulaResultType() == type ); }
/** * Returns the ultimate cell type, following the results of formulas. If * the cell is a {@link CellType#FORMULA}, this returns the result of * {@link Cell#getCachedFormulaResultType()}. Otherwise this returns the * result of {@link Cell#getCellType()}. * * @param cell The cell. * * @return The ultimate type of this cell. */ public static CellType ultimateType(Cell cell) { CellType type = cell.getCellType(); if (type == CellType.FORMULA) return cell.getCachedFormulaResultType(); else return type; }
for(Cell cell : row) { if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) { System.out.println("Formula is " + cell.getCellFormula()); switch(cell.getCachedFormulaResultType()) { case Cell.CELL_TYPE_NUMERIC: System.out.println("Last evaluated as: " + cell.getNumericCellValue()); break; case Cell.CELL_TYPE_STRING: System.out.println("Last evaluated as \"" + cell.getRichStringCellValue() + "\""); break; } } }
return KCellType.EMPTY; } else if ( type == Cell.CELL_TYPE_FORMULA ) { switch ( cell.getCachedFormulaResultType() ) { case Cell.CELL_TYPE_BLANK: case Cell.CELL_TYPE_ERROR:
outputQuotedString(cell.getCellFormula()); _out.write("</f>"); switch (cell.getCachedFormulaResultType()) { case NUMERIC: double nval = cell.getNumericCellValue();
private ValueAndFormat getCellValue(Cell cell) { if (cell != null) { final String format = cell.getCellStyle().getDataFormatString(); CellType type = cell.getCellType(); if (type == CellType.FORMULA) { type = cell.getCachedFormulaResultType(); } switch (type) { case NUMERIC: return new ValueAndFormat(Double.valueOf(cell.getNumericCellValue()), format, decimalTextFormat); case STRING: case BOOLEAN: return new ValueAndFormat(cell.getStringCellValue(), format); default: break; } } return new ValueAndFormat("", ""); } /**
private void handleNonStringCell(StringBuilder text, Cell cell, DataFormatter formatter) { CellType type = cell.getCellType(); if (type == CellType.FORMULA) { type = cell.getCachedFormulaResultType(); } if (type == CellType.NUMERIC) { CellStyle cs = cell.getCellStyle(); if (cs != null && cs.getDataFormatString() != null) { String contents = formatter.formatRawCellContents( cell.getNumericCellValue(), cs.getDataFormat(), cs.getDataFormatString()); checkMaxTextSize(text, contents); text.append(contents); return; } } // No supported styling applies to this cell String contents = ((XSSFCell)cell).getRawValue(); if (contents != null) { checkMaxTextSize(text, contents); text.append(contents); } }
text.append(contents); } else { if (cell.getCachedFormulaResultType() == CellType.STRING) { handleStringCell(text, cell); } else {
cellType = cell.getCachedFormulaResultType();
List<Double> values = new ArrayList<Double>(); for(Row r : sheet) { Cell c = r.getCell(columnNumber); if(c != null) { if(c.getCellType() == Cell.CELL_TYPE_NUMERIC) { valuesadd(c.getNumericCellValue()); } else if(c.getCellType() == Cell.CELL_TYPE_FORMULA && c.getCachedFormulaResultType() == Cell.CELL_TYPE_NUMERIC) { valuesadd(c.getNumericCellValue()); } } }
copyCellType = srcCell.getCachedFormulaResultType();
public int evaluateFormulaCell(Cell cell) { return cell.getCachedFormulaResultType(); }
public int evaluateFormulaCell(Cell cell) { return cell.getCachedFormulaResultType(); }
@Override public CellType evaluateFormulaCell(Cell cell) { return cell.getCachedFormulaResultType(); } /**
private static CellType ultimateCellType(Cell c) { CellType type = c.getCellType(); if (type == CellType.FORMULA) { type = c.getCachedFormulaResultType(); } return type; }
/** * Note that this assumes the cell cached value is up to date and in sync with data edits * * @param cell The {@link Cell} to check. * @param type The {@link CellType} to check for. * @return true if the cell or cached cell formula result type match the given type */ public static boolean isType(Cell cell, CellType type) { final CellType cellType = cell.getCellType(); return cellType == type || (cellType == CellType.FORMULA && cell.getCachedFormulaResultType() == type ); }
int cellType = cell.getCellType(); handleCell(cell, cellType); private void handleCell(Cell cell, int cellType) { if (HSSFCell.CELL_TYPE_NUMERIC == cellType) System.out.print(cell.getNumericCellValue() + " "); else if (HSSFCell.CELL_TYPE_STRING == cellType) System.out.print(cell.getStringCellValue() + " "); else if (HSSFCell.CELL_TYPE_BOOLEAN == cellType) System.out.print(cell.getBooleanCellValue() + " "); else if (HSSFCell.CELL_TYPE_BLANK == cellType) System.out.print("BLANK "); else if (HSSFCell.CELL_TYPE_FORMULA == cellType) handleCell(cell, cell.getCachedFormulaResultType()); else System.out.print("Unknown cell type " + cellType); }
public int getNativeType() { Cell cell = getCell(); if (cell == null) { return IGrid.CELL_TYPE_BLANK; } CellType type = cell.getCellType(); if (type == CellType.FORMULA) { return getIGridCellType(cell.getCachedFormulaResultType()); } return getIGridCellType(type); }
@Override public Cell adapt(org.apache.poi.ss.usermodel.Cell cell) { if (cell.getCachedFormulaResultType() == CELL_TYPE_ERROR) return new ErrorCell(cell.getErrorCellValue()); return new FormulaCell(cell.getCellFormula()); } },