zoukankan      html  css  js  c++  java
  • java poi Excel导入 整数浮点数转换问题解决

        /**
         * 获取单元格数据
         */
        protected static String getCellValue(Cell cell) {
            String cellValue = "";
            if (cell != null) {
                switch (cell.getCellType()) {
                case Cell.CELL_TYPE_STRING:
                    cellValue = cell.getStringCellValue();
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    String dataFormat = cell.getCellStyle().getDataFormatString();
                    if (DateUtil.isCellDateFormatted(cell)) {
                        cellValue = sdf.format(cell.getDateCellValue());
                    } else if ("@".equals(dataFormat)) {
                        cellValue = df.format(cell.getNumericCellValue());
                    } else {
                        cellValue = String.valueOf(cell.getNumericCellValue());
                        DecimalFormat df = new DecimalFormat("#.#########");
                        cellValue=df.format(Double.valueOf(cellValue));
                    }
                    break;
                case Cell.CELL_TYPE_BOOLEAN:
                    cellValue = String.valueOf(cell.getBooleanCellValue());
                    break;
                case Cell.CELL_TYPE_FORMULA:
                    cellValue = cell.getCellFormula();
                    break;
                default:
                    cellValue = "";
                }
            }
            return cellValue;
        }

  • 相关阅读:
    jquery模拟刮刮乐
    jq默认选中每项第一个
    让一个div水平且垂直居中
    ES6模块的import和export用法总结
    linux 标准目录
    spring 注解配置
    多线程下的两种单例写法
    java版二叉树算法实现
    JAVA版A星算法实现
    对于宫格地图寻最短路径的一个广度搜索算法
  • 原文地址:https://www.cnblogs.com/ckaifeng/p/4988970.html
Copyright © 2011-2022 走看看