Commit 02ef42ca22cd7c6dc6cddadc79775eb133b187aa
Exists in
master
Merge branch 'master' of gitlab.taover.com:taov-erp/com-taover-util
Showing
2 changed files
with
47 additions
and
44 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.68' | 62 | + version '1.1.69' |
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
@@ -458,8 +458,9 @@ public class UtilExcel { | @@ -458,8 +458,9 @@ public class UtilExcel { | ||
458 | // 如果是date类型则 ,获取该cell的date值 | 458 | // 如果是date类型则 ,获取该cell的date值 |
459 | return new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getJavaDate(cell.getNumericCellValue())); | 459 | return new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getJavaDate(cell.getNumericCellValue())); |
460 | } else { | 460 | } else { |
461 | - // 纯数字 | ||
462 | - return df.format(cell.getNumericCellValue()); | 461 | + // 纯数字gaoming 新增兼容浮点型,转成字符串读取,不然小数点被省略了 |
462 | + cell.setCellType(CellType.STRING); | ||
463 | + return UtilString.trimCodePage(cell.getRichStringCellValue().getString()); | ||
463 | } | 464 | } |
464 | }else if(currCellType.compareTo(CellType.BOOLEAN) == 0){ | 465 | }else if(currCellType.compareTo(CellType.BOOLEAN) == 0){ |
465 | return cell.getBooleanCellValue(); | 466 | return cell.getBooleanCellValue(); |
@@ -500,19 +501,21 @@ public class UtilExcel { | @@ -500,19 +501,21 @@ public class UtilExcel { | ||
500 | 501 | ||
501 | public static void main(String args[]){ | 502 | public static void main(String args[]){ |
502 | //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; | 503 | //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; |
503 | -// String filepath = "C:\\Users\\gaoming\\Desktop\\qwer.xls"; | ||
504 | -// List<List<Object>> data = null; | ||
505 | -// | ||
506 | -// try { | ||
507 | -// data = UtilExcel.readExcelAllSheetMap(filepath).get("0"); | ||
508 | -// System.out.println(data); | ||
509 | -// System.out.println(data.size()); | ||
510 | -// System.out.println(UtilExcel.readExcelAllSheetMap(filepath)); | ||
511 | -// } catch (Exception e) { | ||
512 | -// // TODO Auto-generated catch block | ||
513 | -// e.printStackTrace(); | ||
514 | -// } | ||
515 | -// List<Short> styleList = new ArrayList<Short>(); | 504 | + String filepath = "C:\\Users\\gaoming\\Desktop\\mmm.xlsx"; |
505 | + List<List<Object>> data = null; | ||
506 | + | ||
507 | + try { | ||
508 | + Map<String, List<List<Object>>> map = UtilExcel.readExcelAllSheetMap(filepath); | ||
509 | + System.out.println(map); | ||
510 | + data = map.get("0"); | ||
511 | + System.out.println(data); | ||
512 | + System.out.println(data.size()); | ||
513 | + System.out.println(UtilExcel.readExcelAllSheetMap(filepath)); | ||
514 | + } catch (Exception e) { | ||
515 | + // TODO Auto-generated catch block | ||
516 | + e.printStackTrace(); | ||
517 | + } | ||
518 | + List<Short> styleList = new ArrayList<Short>(); | ||
516 | // for(int i=0; i<data.size(); ++i){ | 519 | // for(int i=0; i<data.size(); ++i){ |
517 | // if(i == 1)styleList.add(Short.valueOf(HSSFColor.RED.index)); | 520 | // if(i == 1)styleList.add(Short.valueOf(HSSFColor.RED.index)); |
518 | // else styleList.add(null); | 521 | // else styleList.add(null); |
@@ -521,33 +524,33 @@ public class UtilExcel { | @@ -521,33 +524,33 @@ public class UtilExcel { | ||
521 | // } | 524 | // } |
522 | // System.out.println(""); | 525 | // System.out.println(""); |
523 | // } | 526 | // } |
524 | - try { | ||
525 | - List<String> headerList = new ArrayList<String>(); | ||
526 | - headerList.add("shhe1"); | ||
527 | - headerList.add("shhe2"); | ||
528 | - List<List<List<Object>>> dataList = new ArrayList<List<List<Object>>>(); | ||
529 | - List<List<Object>> list1 = new ArrayList<List<Object>>(); | ||
530 | - List<Object> list11 = new ArrayList<Object>(); | ||
531 | - list11.add("hahaha"); | ||
532 | - list11.add("hahaha"); | ||
533 | - list11.add("hahaha"); | ||
534 | - list1.add(list11); | ||
535 | - | ||
536 | - List<List<Object>> list2 = new ArrayList<List<Object>>(); | ||
537 | - List<Object> list22 = new ArrayList<Object>(); | ||
538 | - list22.add("hahaha2"); | ||
539 | - list22.add("hahaha2"); | ||
540 | - list22.add("hahaha2"); | ||
541 | - list2.add(list22); | ||
542 | - list2.add(list22); | ||
543 | - | ||
544 | - dataList.add(list1); | ||
545 | - dataList.add(list2); | ||
546 | - | ||
547 | - UtilExcel.saveExcelContailSheet(headerList, dataList, "C:\\Users\\gaoming\\Desktop\\qwer.xls"); | ||
548 | - } catch (Exception e) { | ||
549 | - // TODO Auto-generated catch block | ||
550 | - e.printStackTrace(); | ||
551 | - } | 527 | +// try { |
528 | +// List<String> headerList = new ArrayList<String>(); | ||
529 | +// headerList.add("shhe1"); | ||
530 | +// headerList.add("shhe2"); | ||
531 | +// List<List<List<Object>>> dataList = new ArrayList<List<List<Object>>>(); | ||
532 | +// List<List<Object>> list1 = new ArrayList<List<Object>>(); | ||
533 | +// List<Object> list11 = new ArrayList<Object>(); | ||
534 | +// list11.add("hahaha"); | ||
535 | +// list11.add("hahaha"); | ||
536 | +// list11.add("hahaha"); | ||
537 | +// list1.add(list11); | ||
538 | +// | ||
539 | +// List<List<Object>> list2 = new ArrayList<List<Object>>(); | ||
540 | +// List<Object> list22 = new ArrayList<Object>(); | ||
541 | +// list22.add("hahaha2"); | ||
542 | +// list22.add("hahaha2"); | ||
543 | +// list22.add("hahaha2"); | ||
544 | +// list2.add(list22); | ||
545 | +// list2.add(list22); | ||
546 | +// | ||
547 | +// dataList.add(list1); | ||
548 | +// dataList.add(list2); | ||
549 | +// | ||
550 | +// UtilExcel.saveExcelContailSheet(headerList, dataList, "C:\\Users\\gaoming\\Desktop\\qwer.xls"); | ||
551 | +// } catch (Exception e) { | ||
552 | +// // TODO Auto-generated catch block | ||
553 | +// e.printStackTrace(); | ||
554 | +// } | ||
552 | } | 555 | } |
553 | } | 556 | } |