Commit 21a5319f5be05edc012a5508e5c936dd610bf9f5

Authored by gaoming
1 parent 626d93d1
Exists in master

.

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.34'
  62 + version '1.1.35'
63 63 artifactId ARTIFACT_Id
64 64 groupId GROUP_ID
65 65 packaging TYPE
... ...
src/main/java/com/taover/util/UtilExcel.java
... ... @@ -291,6 +291,29 @@ public class UtilExcel {
291 291  
292 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 319 * 读取excel表--当前激活的工作表
... ... @@ -421,13 +444,14 @@ public class UtilExcel {
421 444  
422 445 public static void main(String args[]){
423 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 448 List<List<Object>> data = null;
  449 +
426 450 try {
427 451 data = UtilExcel.readExcel(filepath);
428 452 System.out.println(data);
429 453 System.out.println(data.size());
430   - System.out.println(UtilExcel.readExcelExcludeHideLine(filepath).size());
  454 + System.out.println(UtilExcel.readExcelAllSheetMap(filepath));
431 455 } catch (Exception e) {
432 456 // TODO Auto-generated catch block
433 457 e.printStackTrace();
... ...