RuoYi лет назад: 5
Родитель
Сommit
5174536744

+ 1 - 1
pom.xml

@@ -31,7 +31,7 @@
31
         <commons.fileupload.version>1.3.3</commons.fileupload.version>
31
         <commons.fileupload.version>1.3.3</commons.fileupload.version>
32
         <velocity.version>1.7</velocity.version>
32
         <velocity.version>1.7</velocity.version>
33
         <fastjson.version>1.2.74</fastjson.version>
33
         <fastjson.version>1.2.74</fastjson.version>
34
-		<poi.version>3.17</poi.version>
34
+		<poi.version>4.1.2</poi.version>
35
         <common-pool.version>2.6.2</common-pool.version>
35
         <common-pool.version>2.6.2</common-pool.version>
36
     </properties>
36
     </properties>
37
 
37
 

+ 5 - 8
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java

@@ -16,7 +16,6 @@ import java.util.Map;
16
 import java.util.Set;
16
 import java.util.Set;
17
 import java.util.stream.Collectors;
17
 import java.util.stream.Collectors;
18
 import javax.servlet.http.HttpServletResponse;
18
 import javax.servlet.http.HttpServletResponse;
19
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
20
 import org.apache.poi.ss.usermodel.BorderStyle;
19
 import org.apache.poi.ss.usermodel.BorderStyle;
21
 import org.apache.poi.ss.usermodel.Cell;
20
 import org.apache.poi.ss.usermodel.Cell;
22
 import org.apache.poi.ss.usermodel.CellStyle;
21
 import org.apache.poi.ss.usermodel.CellStyle;
@@ -507,12 +506,10 @@ public class ExcelUtil<T>
507
     {
506
     {
508
         if (ColumnType.STRING == attr.cellType())
507
         if (ColumnType.STRING == attr.cellType())
509
         {
508
         {
510
-            cell.setCellType(CellType.STRING);
511
             cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
509
             cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
512
         }
510
         }
513
         else if (ColumnType.NUMERIC == attr.cellType())
511
         else if (ColumnType.NUMERIC == attr.cellType())
514
         {
512
         {
515
-            cell.setCellType(CellType.NUMERIC);
516
             cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
513
             cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
517
         }
514
         }
518
     }
515
     }
@@ -915,10 +912,10 @@ public class ExcelUtil<T>
915
             Cell cell = row.getCell(column);
912
             Cell cell = row.getCell(column);
916
             if (StringUtils.isNotNull(cell))
913
             if (StringUtils.isNotNull(cell))
917
             {
914
             {
918
-                if (cell.getCellTypeEnum() == CellType.NUMERIC || cell.getCellTypeEnum() == CellType.FORMULA)
915
+                if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA)
919
                 {
916
                 {
920
                     val = cell.getNumericCellValue();
917
                     val = cell.getNumericCellValue();
921
-                    if (HSSFDateUtil.isCellDateFormatted(cell))
918
+                    if (DateUtil.isCellDateFormatted(cell))
922
                     {
919
                     {
923
                         val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
920
                         val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
924
                     }
921
                     }
@@ -934,15 +931,15 @@ public class ExcelUtil<T>
934
                         }
931
                         }
935
                     }
932
                     }
936
                 }
933
                 }
937
-                else if (cell.getCellTypeEnum() == CellType.STRING)
934
+                else if (cell.getCellType() == CellType.STRING)
938
                 {
935
                 {
939
                     val = cell.getStringCellValue();
936
                     val = cell.getStringCellValue();
940
                 }
937
                 }
941
-                else if (cell.getCellTypeEnum() == CellType.BOOLEAN)
938
+                else if (cell.getCellType() == CellType.BOOLEAN)
942
                 {
939
                 {
943
                     val = cell.getBooleanCellValue();
940
                     val = cell.getBooleanCellValue();
944
                 }
941
                 }
945
-                else if (cell.getCellTypeEnum() == CellType.ERROR)
942
+                else if (cell.getCellType() == CellType.ERROR)
946
                 {
943
                 {
947
                     val = cell.getErrorCellValue();
944
                     val = cell.getErrorCellValue();
948
                 }
945
                 }