从excel中分解标准号

This commit is contained in:
zhaokaiyao@91isoft.com
2021-11-12 15:59:17 +08:00
parent 7d8e716ea2
commit 1f74918c7f
2 changed files with 19 additions and 4 deletions
@@ -25,6 +25,9 @@ public class Analysis {
private static final Logger logger = LoggerFactory.getLogger(Contrast.class);
private int sortColumn=0;
public void run(MultipartFile file, MultipartFile sort) throws IOException {
InputStream inputStream = file.getInputStream();
@@ -37,7 +40,7 @@ public class Analysis {
for (Row row : sheet) {
if (row.getCell(1)!=null){
//获取表1的标准号
String value = row.getCell(1).toString().trim();
String value = row.getCell(1).toString();
Cell sortCell = row.createCell(11);
Cell sortNumber = row.createCell(12);
Cell sortYear = row.createCell(13);
@@ -96,13 +99,24 @@ public class Analysis {
}
}
}
File result = new File("C:\\Users\\22501\\Desktop\\foton标准数据\\拆分标准号-海外.xlsx");
File result = new File("C:\\Users\\22501\\Desktop\\foton标准数据\\拆分标准号-企标.xlsx");
FileOutputStream os = new FileOutputStream(result);
workbook.write(os);
// HashMap<String, String> map = new HashMap<>();
}
public void setSortColumn(int sortColumn){
this.sortColumn=sortColumn;
}
/**
* 获取标准类别set集合
* @param file
* @return
* @throws IOException
*/
private HashSet<String> getSet(MultipartFile file) throws IOException {
InputStream inputStream = file.getInputStream();
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
@@ -114,8 +128,8 @@ public class Analysis {
HashSet<String> stringHashSet= new HashSet<>();
for (Row row : sheet) {
if (row.getCell(0)!=null){
stringHashSet.add(row.getCell(0).toString().trim());
if (row.getCell(sortColumn)!=null){
stringHashSet.add(row.getCell(sortColumn).toString());
}
}
@@ -152,6 +152,7 @@ public class ImportExcelController extends BaseController<ImportDto> {
@PostMapping("/analysis")
public void analysis(MultipartFile exclFile,MultipartFile standSort) throws IOException {
Analysis analysis = new Analysis();
analysis.setSortColumn(1);
analysis.run(exclFile,standSort);
}
}