|
@@ -10,10 +10,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
public class ExcelUtil {
|
|
public class ExcelUtil {
|
|
|
|
|
|
@@ -65,7 +62,7 @@ public class ExcelUtil {
|
|
//行List,也是最终要返回的List
|
|
//行List,也是最终要返回的List
|
|
List<HashMap<Integer,String>> rowList=new ArrayList<>();
|
|
List<HashMap<Integer,String>> rowList=new ArrayList<>();
|
|
Workbook workbook=getExcelWorkBook(multipartFile);
|
|
Workbook workbook=getExcelWorkBook(multipartFile);
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(1);
|
|
if (sheet == null) {
|
|
if (sheet == null) {
|
|
throw new IOException("创建Sheet失败!");
|
|
throw new IOException("创建Sheet失败!");
|
|
}
|
|
}
|
|
@@ -80,7 +77,6 @@ public class ExcelUtil {
|
|
if(ObjectUtils.isNotEmpty(cell)){
|
|
if(ObjectUtils.isNotEmpty(cell)){
|
|
DataFormatter dataFormatter = new DataFormatter();
|
|
DataFormatter dataFormatter = new DataFormatter();
|
|
String cellValue = dataFormatter.formatCellValue(cell);
|
|
String cellValue = dataFormatter.formatCellValue(cell);
|
|
- System.out.println(cellValue);
|
|
|
|
map.put(cellNum,cellValue);
|
|
map.put(cellNum,cellValue);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,7 +87,20 @@ public class ExcelUtil {
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
public static void main(String[] args) throws IOException {
|
|
- getExcelRowList(new File("D:\\abc\\111111\\rtk账号导入模板 (1).xlsx"));
|
|
|
|
|
|
+ HashSet<String> strings = new HashSet<>();
|
|
|
|
+ List<HashMap<Integer, String>> excelRowList = getExcelRowList(new File("D:\\abc\\111111\\物料创建9.20.xlsx"));
|
|
|
|
+ Integer index = 0;
|
|
|
|
+ for (HashMap<Integer, String> map : excelRowList) {
|
|
|
|
+ index ++;
|
|
|
|
+ if(index == 1){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String num = map.get(1).trim();
|
|
|
|
+ if(strings.contains(num)){
|
|
|
|
+ System.out.println("重复:"+num);
|
|
|
|
+ }
|
|
|
|
+ strings.add(num);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|