使用poi中的getCellTypeEnum()枚举返回类型描述

CellTypeEnum        类型        值

NUMERIC             数值型        0

STRING              字符串型      1

FORMULA            公式型        2

BLANK                    空值         3

BOOLEAN             布尔型       4

ERROR                   错误         5

部分应用:

switch (cell.getCellTypeEnum()) {
    case NUMERIC:
        if (DateUtil.isCellDateFormatted(cell)) {
            Date date = cell.getDateCellValue();
            DateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
            cols[k] = formater.format(date);
        } else if (String.valueOf(cell.getNumericCellValue()).contains(".")) {
            DecimalFormat df = new DecimalFormat("#");
            cols[k] = df.format(cell.getNumericCellValue());
        } else {
            cols[k] = (cell + "").trim();
        }
        continue;
    default:
        cols[k] = (cell + "").trim();
        continue;
    }

 

你可能感兴趣的:(使用poi中的getCellTypeEnum()枚举返回类型描述)