Commit 711787ac5f0ebb54fa487fad36323050f6a2bec5

Authored by gaoming
1 parent 8b983115
Exists in master

优化excel读取时间

build.gradle
... ... @@ -59,7 +59,7 @@ uploadArchives {
59 59 authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
60 60 }
61 61 pom.project {
62   - version '1.1.79'
  62 + version '1.1.80'
63 63 artifactId ARTIFACT_Id
64 64 groupId GROUP_ID
65 65 packaging TYPE
... ...
src/main/java/com/taover/util/UtilExcel.java
... ... @@ -446,7 +446,19 @@ public class UtilExcel {
446 446 if(currCellType.compareTo(CellType.STRING) == 0){
447 447 return UtilString.trimCodePage(cell.getRichStringCellValue().getString());
448 448 }else if(currCellType.compareTo(CellType.NUMERIC) == 0){
449   - if (cell.getCellStyle().getDataFormat()==28||cell.getCellStyle().getDataFormat()==31 || cell.getCellStyle().getDataFormat() == 58) {
  449 +
  450 + /**
  451 + * yyyy-MM-dd----- 14
  452 + yyyy年m月d日--- 31
  453 + yyyy年m月------- 57
  454 + m月d日 ---------- 58
  455 + HH:mm----------- 20
  456 + h时mm分 ------- 32
  457 + */
  458 + System.out.println(cell.getCellStyle().getDataFormat());
  459 + if (cell.getCellStyle().getDataFormat()==28||cell.getCellStyle().getDataFormat()==31
  460 + || cell.getCellStyle().getDataFormat() == 58 || cell.getCellStyle().getDataFormat()==14
  461 + || cell.getCellStyle().getDataFormat()==57 || cell.getCellStyle().getDataFormat()==32 || cell.getCellStyle().getDataFormat()==20) {
450 462 // 如果是date类型则 ,获取该cell的date值
451 463 return new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getJavaDate(cell.getNumericCellValue()));
452 464 } else {
... ... @@ -489,7 +501,7 @@ public class UtilExcel {
489 501  
490 502 public static void main(String args[]){
491 503 //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx";
492   - String filepath = "C:\\Users\\gaoming\Desktop\mmm.xlsx";
  504 + String filepath = "C:\\Users\\EDZ\Desktop\mmm.xlsx";
493 505 List<List<Object>> data = null;
494 506  
495 507 try {
... ...