Example usage for org.apache.poi.ss.formula.eval ErrorEval valueOf

List of usage examples for org.apache.poi.ss.formula.eval ErrorEval valueOf

Introduction

In this page you can find the example usage for org.apache.poi.ss.formula.eval ErrorEval valueOf.

Prototype

public static ErrorEval valueOf(int errorCode) 

Source Link

Document

Translates an Excel internal error code into the corresponding POI ErrorEval instance

Usage

From source file:com.dataart.spreadsheetanalytics.engine.ConverterUtils.java

License:Apache License

/** Returns the new {@link CellValue} from provided {@link org.apache.poi.ss.usermodel.CellValue}. */
public static ICellValue resolveCellValue(org.apache.poi.ss.usermodel.CellValue cellval) {
    if (cellval == null) {
        return CellValue.BLANK;
    }/*ww w .  j av  a  2 s  . co m*/

    switch (cellval.getCellType()) {
    case CELL_TYPE_NUMERIC: {
        return CellValue.from(cellval.getNumberValue());
    }
    case CELL_TYPE_STRING: {
        return CellValue.from(cellval.getStringValue());
    }
    case CELL_TYPE_BOOLEAN: {
        return CellValue.from(cellval.getBooleanValue());
    }
    case CELL_TYPE_ERROR: {
        return CellValue.from(ErrorEval.valueOf(cellval.getErrorValue()).getErrorString());
    }
    case CELL_TYPE_BLANK: {
        return CellValue.BLANK;
    }
    case CELL_TYPE_FORMULA: {
        throw new CalculationEngineException("Result of evaluation cannot be a formula.");
    }
    default: {
        throw new CalculationEngineException(
                String.format("CellValue's tType %s is not supported.", cellval.getCellType()));
    }
    }
}