Example usage for org.apache.poi.ss.usermodel CellValue getError

List of usage examples for org.apache.poi.ss.usermodel CellValue getError

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel CellValue getError.

Prototype

public static CellValue getError(int errorCode) 

Source Link

Usage

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();
    }//ww  w .j  av a  2 s  .  co  m
    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:org.paxml.table.excel.ExcelFile.java

License:Open Source License

public Object getCellValue(Cell cell) {
    CellValue cellValue = evaluator.evaluate(cell);
    switch (cellValue.getCellType()) {
    case Cell.CELL_TYPE_BOOLEAN:
        return cellValue.getBooleanValue();
    case Cell.CELL_TYPE_NUMERIC:
        return cellValue.getNumberValue();
    case Cell.CELL_TYPE_STRING:
        return cellValue.getStringValue();
    case Cell.CELL_TYPE_BLANK:
        return "";
    case Cell.CELL_TYPE_ERROR:
        return cellValue.getError(cell.getErrorCellValue()).getStringValue();
    // CELL_TYPE_FORMULA will never happen
    case Cell.CELL_TYPE_FORMULA:
        throw new PaxmlRuntimeException("Internal error: invalid case");
    default://w ww  . j a va2  s . c o m
        return null;
    }
}