private String convertCellValueToString() { int cellType = getCellType(); switch (cellType) { case CELL_TYPE_BLANK: return ""; case CELL_TYPE_BOOLEAN: return getBooleanCellValue() ? "TRUE" : "FALSE"; case CELL_TYPE_STRING: return getStringCellValue(); case CELL_TYPE_NUMERIC: case CELL_TYPE_ERROR: byte errVal = getErrorCellValue(); return FormulaError.forInt(errVal).getString(); case CELL_TYPE_FORMULA: return ""; default: throw new IllegalStateException("Unexpected cell type (" + cellType + ")"); } }
/** * Set a error value for the cell * * @param errorCode the error value to set this cell to. For formulas we'll set the precalculated * value , for errors we'll set its value. For other types we will change the cell to an error * cell and set its value. * @see FormulaError */ public void setCellErrorValue(byte errorCode) { FormulaError error = FormulaError.forInt(errorCode); setCellErrorValue(error); }