Commit 21a5319f5be05edc012a5508e5c936dd610bf9f5
1 parent
626d93d1
Exists in
master
.
Showing
2 changed files
with
27 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.34' | 62 | + version '1.1.35' |
| 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
| @@ -291,6 +291,29 @@ public class UtilExcel { | @@ -291,6 +291,29 @@ public class UtilExcel { | ||
| 291 | 291 | ||
| 292 | return result; | 292 | return result; |
| 293 | } | 293 | } |
| 294 | + | ||
| 295 | + | ||
| 296 | + /** | ||
| 297 | + * 读取excel表--所有工作表 Map封装 | ||
| 298 | + * @param path | ||
| 299 | + */ | ||
| 300 | + public static Map<String,List<List<Object>>> readExcelAllSheetMap(String filepath) throws Exception{ | ||
| 301 | + File file = new File(filepath); | ||
| 302 | + HashMap<String, List<List<Object>>> map = new HashMap<String,List<List<Object>>>(); | ||
| 303 | + if(!file.exists()){ | ||
| 304 | + throw new Exception("Excel["+filepath+"]文件不存在"); | ||
| 305 | + } | ||
| 306 | + Workbook wb = UtilExcel.getWorkbook(filepath, true); | ||
| 307 | + int sheetNumber = wb.getNumberOfSheets(); | ||
| 308 | + | ||
| 309 | + for(int sheetIndex=0; sheetIndex<sheetNumber; ++sheetIndex){ | ||
| 310 | + map.put(sheetIndex+"",(readExcelBySheetIndexExcludeHideLine(filepath, sheetIndex))); | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + return map; | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + | ||
| 294 | 317 | ||
| 295 | /** | 318 | /** |
| 296 | * 读取excel表--当前激活的工作表 | 319 | * 读取excel表--当前激活的工作表 |
| @@ -421,13 +444,14 @@ public class UtilExcel { | @@ -421,13 +444,14 @@ public class UtilExcel { | ||
| 421 | 444 | ||
| 422 | public static void main(String args[]){ | 445 | public static void main(String args[]){ |
| 423 | //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; | 446 | //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; |
| 424 | - String filepath = "C:\\Users\\EDZ\\Desktop\\qwer.xlsx"; | 447 | + String filepath = "C:\\Users\\EDZ\\Desktop\\qwer.xls"; |
| 425 | List<List<Object>> data = null; | 448 | List<List<Object>> data = null; |
| 449 | + | ||
| 426 | try { | 450 | try { |
| 427 | data = UtilExcel.readExcel(filepath); | 451 | data = UtilExcel.readExcel(filepath); |
| 428 | System.out.println(data); | 452 | System.out.println(data); |
| 429 | System.out.println(data.size()); | 453 | System.out.println(data.size()); |
| 430 | - System.out.println(UtilExcel.readExcelExcludeHideLine(filepath).size()); | 454 | + System.out.println(UtilExcel.readExcelAllSheetMap(filepath)); |
| 431 | } catch (Exception e) { | 455 | } catch (Exception e) { |
| 432 | // TODO Auto-generated catch block | 456 | // TODO Auto-generated catch block |
| 433 | e.printStackTrace(); | 457 | e.printStackTrace(); |