ソースを参照

升级poi到最新版本4.1.2

RuoYi 5 年 前
コミット
5174536744
共有2 個のファイルを変更した6 個の追加9 個の削除を含む
  1. 1 1
      pom.xml
  2. 5 8
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java

+ 1 - 1
pom.xml

@@ -31,7 +31,7 @@
31 31
         <commons.fileupload.version>1.3.3</commons.fileupload.version>
32 32
         <velocity.version>1.7</velocity.version>
33 33
         <fastjson.version>1.2.74</fastjson.version>
34
-		<poi.version>3.17</poi.version>
34
+		<poi.version>4.1.2</poi.version>
35 35
         <common-pool.version>2.6.2</common-pool.version>
36 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 16
 import java.util.Set;
17 17
 import java.util.stream.Collectors;
18 18
 import javax.servlet.http.HttpServletResponse;
19
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
20 19
 import org.apache.poi.ss.usermodel.BorderStyle;
21 20
 import org.apache.poi.ss.usermodel.Cell;
22 21
 import org.apache.poi.ss.usermodel.CellStyle;
@@ -507,12 +506,10 @@ public class ExcelUtil<T>
507 506
     {
508 507
         if (ColumnType.STRING == attr.cellType())
509 508
         {
510
-            cell.setCellType(CellType.STRING);
511 509
             cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
512 510
         }
513 511
         else if (ColumnType.NUMERIC == attr.cellType())
514 512
         {
515
-            cell.setCellType(CellType.NUMERIC);
516 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 912
             Cell cell = row.getCell(column);
916 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 917
                     val = cell.getNumericCellValue();
921
-                    if (HSSFDateUtil.isCellDateFormatted(cell))
918
+                    if (DateUtil.isCellDateFormatted(cell))
922 919
                     {
923 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 936
                     val = cell.getStringCellValue();
940 937
                 }
941
-                else if (cell.getCellTypeEnum() == CellType.BOOLEAN)
938
+                else if (cell.getCellType() == CellType.BOOLEAN)
942 939
                 {
943 940
                     val = cell.getBooleanCellValue();
944 941
                 }
945
-                else if (cell.getCellTypeEnum() == CellType.ERROR)
942
+                else if (cell.getCellType() == CellType.ERROR)
946 943
                 {
947 944
                     val = cell.getErrorCellValue();
948 945
                 }