Commit 711787ac5f0ebb54fa487fad36323050f6a2bec5
1 parent
8b983115
Exists in
master
优化excel读取时间
Showing
2 changed files
with
15 additions
and
3 deletions
Show diff stats
build.gradle
@@ -59,7 +59,7 @@ uploadArchives { | @@ -59,7 +59,7 @@ uploadArchives { | ||
59 | authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) | 59 | authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) |
60 | } | 60 | } |
61 | pom.project { | 61 | pom.project { |
62 | - version '1.1.79' | 62 | + version '1.1.80' |
63 | artifactId ARTIFACT_Id | 63 | artifactId ARTIFACT_Id |
64 | groupId GROUP_ID | 64 | groupId GROUP_ID |
65 | packaging TYPE | 65 | packaging TYPE |
src/main/java/com/taover/util/UtilExcel.java
@@ -446,7 +446,19 @@ public class UtilExcel { | @@ -446,7 +446,19 @@ public class UtilExcel { | ||
446 | if(currCellType.compareTo(CellType.STRING) == 0){ | 446 | if(currCellType.compareTo(CellType.STRING) == 0){ |
447 | return UtilString.trimCodePage(cell.getRichStringCellValue().getString()); | 447 | return UtilString.trimCodePage(cell.getRichStringCellValue().getString()); |
448 | }else if(currCellType.compareTo(CellType.NUMERIC) == 0){ | 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 | // 如果是date类型则 ,获取该cell的date值 | 462 | // 如果是date类型则 ,获取该cell的date值 |
451 | return new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getJavaDate(cell.getNumericCellValue())); | 463 | return new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getJavaDate(cell.getNumericCellValue())); |
452 | } else { | 464 | } else { |
@@ -489,7 +501,7 @@ public class UtilExcel { | @@ -489,7 +501,7 @@ public class UtilExcel { | ||
489 | 501 | ||
490 | public static void main(String args[]){ | 502 | public static void main(String args[]){ |
491 | //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; | 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 | List<List<Object>> data = null; | 505 | List<List<Object>> data = null; |
494 | 506 | ||
495 | try { | 507 | try { |