From 701f43e193b6277bd3686b1940c32ac9d7ba74f8 Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期三, 07 九月 2022 11:32:14 +0800
Subject: [PATCH] 软件excel解析

---
 src/main/java/com/whyc/service/SoftwareService.java |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/whyc/service/SoftwareService.java b/src/main/java/com/whyc/service/SoftwareService.java
index 5ad01e7..363ddb3 100644
--- a/src/main/java/com/whyc/service/SoftwareService.java
+++ b/src/main/java/com/whyc/service/SoftwareService.java
@@ -11,6 +11,7 @@
 import com.whyc.pojo.Software;
 import com.whyc.util.ActionUtil;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
@@ -23,7 +24,6 @@
 import java.io.*;
 import java.net.URLEncoder;
 import java.text.ParseException;
-import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -55,7 +55,7 @@
         for (int i = 0; i < typeArr.length; i++) {
             //excel鍗曞厓鏍间腑鐨勨湐瀵瑰簲瀛楃
             if(typeArr[i].contains("镁")){
-                common.setType(typeArr[i].trim());
+                common.setType(typeArr[i].replace("镁","").trim());
                 break;
             }
         }
@@ -63,8 +63,7 @@
         common.setBasedVersion(sheet.getRow(4).getCell(4).getStringCellValue());
 
         common.setOwner(sheet.getRow(5).getCell(2).getStringCellValue());
-        Date filingDate = sheet.getRow(5).getCell(4).getDateCellValue();
-        common.setFilingDate(filingDate);
+        common.setFilingDate(sheet.getRow(5).getCell(4).getStringCellValue());
         //鏈�鍚庝竴琛�,鍙栧彂甯冭鏄�
         common.setReleaseNotes(sheet.getRow(lastRowNum).getCell(2).getStringCellValue());
 
@@ -74,8 +73,10 @@
             Software software = new Software();
             BeanUtils.copyProperties(common,software);
             //鍙栫3鍒�,绗�5鍒�
-            software.setApplyMaterialCode(sheet.getRow(8+i).getCell(2).getStringCellValue());
-            software.setApplyModel(sheet.getRow(8+i).getCell(4).getStringCellValue());
+            Cell cell = sheet.getRow(7 + i).getCell(2);
+            cell.setCellType(Cell.CELL_TYPE_STRING);
+            software.setApplyMaterialCode(cell.getStringCellValue());
+            software.setApplyModel(sheet.getRow(7+i).getCell(4).getStringCellValue());
 
             softwareList.add(software);
         }

--
Gitblit v1.9.1