List of usage examples for org.apache.poi.ss.usermodel FormulaError forString
public static FormulaError forString(String code) throws IllegalArgumentException
From source file:com.dataart.spreadsheetanalytics.engine.ConverterUtils.java
License:Apache License
/** Inserts a value to a Cell based on a value type (class). */ static void populateCellValue(final Cell cell, final ICellValue value) { if (cell == null) { return;//w w w. j a v a 2 s. c o m } int cellType = resolveCellType(value); cell.setCellType(cellType); switch (cellType) { case CELL_TYPE_BLANK: { break; } case CELL_TYPE_BOOLEAN: { cell.setCellValue((Boolean) value.get()); break; } case CELL_TYPE_NUMERIC: { cell.setCellValue((Double) value.get()); break; } case CELL_TYPE_FORMULA: { try { cell.setCellFormula(((String) value.get()).substring(1)); break; } catch (FormulaParseNameException e) { log.error("Formula parsing error while trying to set formula field in cell " + e.getMessage()); cell.setCellFormula(ErrorEval.NAME_INVALID.getErrorString()); break; } catch (FormulaParseNAException e) { log.error("Formula parsing error while trying to set formula field in cell " + e.getMessage()); cell.setCellFormula(ErrorEval.NA.getErrorString()); break; } } case CELL_TYPE_ERROR: { cell.setCellErrorValue(FormulaError.forString((String) value.get()).getCode()); break; } case CELL_TYPE_STRING: { cell.setCellValue((String) value.get()); break; } default: { throw new CalculationEngineException(String.format("Type of value %s is not supported: %s", value, value.getClass().getSimpleName())); } } }
From source file:com.dataart.spreadsheetanalytics.engine.PoiWorkbookConverters.java
License:Apache License
public int getErrorCellValue() { if (CELL_TYPE_ERROR != ConverterUtils.resolveCellType(this.value)) { throw new CalculationEngineException("Trying to get error value from non-error cell."); }//from w ww .java 2 s. c o m return FormulaError.forString((String) this.value.get()).getCode(); }