zoukankan      html  css  js  c++  java
  • poi excel单元格的校验

    switch (cell.getCellType()) {
    case HSSFCell.CELL_TYPE_NUMERIC://数值类型
    if (0 == cell.getCellType()) {
    if (HSSFDateUtil.isCellDateFormatted(cell)) {
    Date date = cell.getDateCellValue();
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    cellValue = formatter.format(date);
    } else {
             //存储整型类型的数据
    double doubleValue = cell.getNumericCellValue();
    long longValue = Math.round(doubleValue);
    if (Double.parseDouble(longValue + ".0") == doubleValue) {
    cellValue = longValue + "";
    } else {
    cellValue = doubleValue + "";
    }
    }
    }
    break;
    case HSSFCell.CELL_TYPE_STRING://字符串
    cellValue = cell.getStringCellValue();
    break;
    case HSSFCell.CELL_TYPE_BOOLEAN://boolean值
    cellValue = cell.getBooleanCellValue() + "";
    break;
    case HSSFCell.CELL_TYPE_FORMULA:
    cellValue = cell.getCellFormula() + "";
    break;
    case HSSFCell.CELL_TYPE_BLANK://空值
    cellValue = "";
    break;
    case HSSFCell.CELL_TYPE_ERROR://错误
    cellValue = "非法字符";
    break;
    default:
    cellValue = "未知类型";
    break;
    }
  • 相关阅读:
    ACdream 1224 Robbers (贪心)
    HDU 4320 Arcane Numbers 1 (质因子分解)
    在脚本中重定向输入
    呈现数据
    shell中的for、while、until(二)
    shell中的for、while、until
    C 指针疑虑
    结构化命令
    fdisk -c 0 350 1000 300命令
    PC机上的COM1口和COM2口
  • 原文地址:https://www.cnblogs.com/lsj-info/p/9476309.html
Copyright © 2011-2022 走看看