RT:
例如:  abc6.0我导入的话 只导入了abc6  、    .0 就不见了。  但是abc6.1   就可以完整导入、  该怎么解决这个问题? 谢谢

解决方案 »

  1.   

    不知道楼主怎么导入的
    如果cell.setCellValue("abc6.0");这样,是可以完整导入的!
    要不你把那个单元格设置成String格式的cell.setCellType(Cell.CELL_TYPE_STRING);
      

  2.   

    excel里面的单元格不管设置什么类型,在java后台获取的String类型  都是这样,少个.0、   我刚才做了个实验, 我把 abc6.0  后面敲个空格就能正常导入进去. 但是不能要求别人这样做、 纠结中...
      

  3.   

    你getCellType看看是什么类型的。
      

  4.   


    返回是  int类型 /**
         * 根据cell类型自动获取数据
         * @param cell 单元格对象
         * @return 获取到的数据
         */
        private static String getValueFromCell(XSSFCell cell)
        {
            if (cell != null)
            {
                switch (cell.getCellType())
                {
                    case XSSFCell.CELL_TYPE_BLANK:
                        return "";
                    case HSSFCell.CELL_TYPE_BOOLEAN:
                        return BooleanUtils.toStringTrueFalse(cell.getBooleanCellValue());
                    case XSSFCell.CELL_TYPE_NUMERIC:
                        //                    java.text.DecimalFormat formatter = new java.text.DecimalFormat("########");
                        //                    String str = formatter.format(cell.getNumericCellValue());
                        return String.valueOf(cell.getNumericCellValue());
                    case XSSFCell.CELL_TYPE_ERROR:
                        return "#ERROR:" + cell.getErrorCellValue();
                    case XSSFCell.CELL_TYPE_STRING:
                        return cell.getRichStringCellValue().getString();
                    default:
                        return cell.getRichStringCellValue().getString();
                }
            }
            else
            {
                return "";
            }
        }
      

  5.   

    找到原因了..
    /**
                                         * 格式化单元格
                                         */
                                        while (cellData.endsWith(".0"))
                                        {
                                            cellData =
                                                cellData.substring(0,
                                                    cellData.length() - 2);
                                        }
    这里别截取了.
      

  6.   

    找到原因了..
    /**
                                         * 格式化单元格
                                         */
                                        while (cellData.endsWith(".0"))
                                        {
                                            cellData =
                                                cellData.substring(0,
                                                    cellData.length() - 2);
                                        }
    这里别截取了.代码应该看清楚才行滴