diff --git a/build.gradle b/build.gradle index 29a8d04..04d5f24 100644 --- a/build.gradle +++ b/build.gradle @@ -59,7 +59,7 @@ uploadArchives { authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) } pom.project { - version '1.1.80' + version '1.1.82' artifactId ARTIFACT_Id groupId GROUP_ID packaging TYPE diff --git a/src/main/java/com/taover/util/UtilExcel.java b/src/main/java/com/taover/util/UtilExcel.java index 15f96cd..eacd7cf 100644 --- a/src/main/java/com/taover/util/UtilExcel.java +++ b/src/main/java/com/taover/util/UtilExcel.java @@ -2,6 +2,7 @@ package com.taover.util; import java.io.File; import java.io.FileOutputStream; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -10,6 +11,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.poi.hssf.usermodel.HSSFDataFormatter; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; @@ -461,10 +463,10 @@ public class UtilExcel { || cell.getCellStyle().getDataFormat()==57 || cell.getCellStyle().getDataFormat()==32 || cell.getCellStyle().getDataFormat()==20) { // 如果是date类型则 ,获取该cell的date值 return new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getJavaDate(cell.getNumericCellValue())); - } else { - // 纯数字gaoming 新增兼容浮点型,转成字符串读取,不然小数点被省略了 - cell.setCellType(CellType.STRING); - return UtilString.trimCodePage(cell.getRichStringCellValue().getString()); + } else { + //gaoming 这个是poi自带获取value通用,如果再有问题就用这个试试!!! + HSSFDataFormatter dataFormatter = new HSSFDataFormatter(); + return dataFormatter.formatCellValue(cell); } }else if(currCellType.compareTo(CellType.BOOLEAN) == 0){ return cell.getBooleanCellValue(); @@ -501,7 +503,7 @@ public class UtilExcel { public static void main(String args[]){ //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; - String filepath = "C:\\Users\\EDZ\\Desktop\\mmm.xlsx"; + String filepath = "C:\\Users\\EDZ\\Desktop\\aaa.xlsx"; List> data = null; try { -- libgit2 0.21.2