diff --git a/test/src/main/java/ExcelUtils.java b/test/src/main/java/ExcelUtils.java index ab0d1388c..7fb243181 100644 --- a/test/src/main/java/ExcelUtils.java +++ b/test/src/main/java/ExcelUtils.java @@ -14,7 +14,7 @@ public class ExcelUtils { private static Set oldFileNames = new HashSet<>(); private static String javaFilePath = "tablemanager/src/main/java/config/"; - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws Exception { File oldfile = new File(path); String[] list = oldfile.list(); oldFileNames.addAll(Arrays.asList(list)); @@ -96,7 +96,7 @@ public class ExcelUtils { System.out.println(getInfos); } - public static void readExcelData() throws IOException { + public static void readExcelData() throws Exception { File file = new File(excelPath); if (file.exists()) { File[] files = file.listFiles(); @@ -144,7 +144,7 @@ public class ExcelUtils { return fieldInfo; } - private static void buildDataInfo(Workbook wb) throws IOException { + private static void buildDataInfo(Workbook wb) throws Exception { Sheet sheet; Row row; Object cellData; @@ -154,6 +154,7 @@ public class ExcelUtils { int rownum = sheet.getLastRowNum(); FileWriter fw = new FileWriter(path + sheetName + ".txt"); PrintWriter out = new PrintWriter(fw); + Set indexCheck = new HashSet<>(); for (int i = 0; i <= rownum; i++) { if (i == 2 || i == 3 || i == 4 ||i == 5||i == 6){ continue; @@ -191,6 +192,17 @@ public class ExcelUtils { }else{ info.append("\t").append(cellData); } + if(i>2&&j==1){ + try { + if(indexCheck.contains(cellData)){ + throw new Exception("\r\ncollection:="+sheetName+" 重复\r\n :index: "+cellData+"\r\n :row:"+(i+1)); + } + indexCheck.add(Integer.valueOf(cellData.toString())); + }catch (ClassCastException e){ + System.out.println("wb = [" + e + "]"); + } + + } } } out.write(info.toString());