java使用poi导入excel表处理小数点

导入excel表,若表格中为整数数字,不管单元格设置成数字格式还是文本格式,导入时都会出现小数点和0

/**
 * 处理导入小数点
 */
public  static String  numOfImport(HSSFCell cell) {
    String value = cell.toString();
    int i = cell.getCellType();
    if (i == 1) {//字符串类型
        return value;
    } else {
        String[] str = value.split("\\.");
        if (str.length > 1) {
            String str1 = str[1];
            int m = Integer.parseInt(str1);
            if (m == 0) {
                return str[0];
            } else {
                return value;
            }
        }else{
            return value;
        }
    }


}

发布了30 篇原创文章 · 获赞 33 · 访问量 2万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章