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;
        }

  • 相关阅读:
    [LoadRunner]UTF8字符格式
    Python的数字类型及其技巧
    Python的数据类型总结
    理解Python的迭代器
    一篇文章让你彻底搞清楚Python中self的含义
    Python中类的运算符重载
    深入理解Python中的生成器
    模态窗口点滴
    ASP.NET 防盗链的实现[HttpHandler]
    ASP.NET C# DataTable与Excel互操作示例
  • 原文地址:https://www.cnblogs.com/ckaifeng/p/4988970.html
Copyright © 2011-2022 走看看