Commit 711787ac5f0ebb54fa487fad36323050f6a2bec5
1 parent
8b983115
Exists in
master
优化excel读取时间
Showing
2 changed files
with
15 additions
and
3 deletions
Show diff stats
build.gradle
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 { | ... | ... |