Explorar el Código

feat: poi版本5.2.3

zhangkai hace 3 meses
padre
commit
2645272276

+ 0 - 4
nationrel-module-alta-api/pom.xml

@@ -29,22 +29,18 @@
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi</artifactId>
-            <version>3.9</version>
         </dependency>
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-scratchpad</artifactId>
-            <version>3.9</version>
         </dependency>
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-ooxml</artifactId>
-            <version>3.9</version>
         </dependency>
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-excelant</artifactId>
-            <version>3.9</version>
         </dependency>
         <!--  poi End -->
         <dependency>

+ 7 - 8
nationrel-module-alta-api/src/main/java/com/nationrel/modules/alta/util/ExportExcelUtil.java

@@ -1,11 +1,10 @@
 package com.nationrel.modules.alta.util;
 
-import com.nationrel.modules.alta.general.util.common.ValidateUtils;
 import com.nationrel.modules.alta.constant.AltaConstants;
+import com.nationrel.modules.alta.general.util.common.ValidateUtils;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.hssf.util.HSSFColor;
-import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
 
 import java.io.OutputStream;
@@ -59,10 +58,10 @@ public class ExportExcelUtil {
             //创建单元格,并设置值表头 设置表头居中
             XSSFCellStyle titleCellStyle = wb.createCellStyle();
             XSSFCellStyle cellStyle = wb.createCellStyle();
-            cellStyle.setAlignment( XSSFCellStyle.ALIGN_CENTER);
-            cellStyle.setVerticalAlignment( XSSFCellStyle.VERTICAL_CENTER);
+            cellStyle.setAlignment(HorizontalAlignment.CENTER);
+            cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
             // 设置:表头Cell样式
-            writeCellStyle(titleCellStyle, XSSFCellStyle.SOLID_FOREGROUND, HSSFColor.LIME.index, XSSFCellStyle.ALIGN_CENTER, XSSFCellStyle.VERTICAL_CENTER);
+            writeCellStyle(titleCellStyle, FillPatternType.SOLID_FOREGROUND, IndexedColors.LIME.index, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
             // 填充工作表
             fillSheet(sheet, list, fieldMap, titleCellStyle, cellStyle);
 
@@ -241,8 +240,8 @@ public class ExportExcelUtil {
      * @param alignment         设置单元格的水平对齐类型
      * @param verticalAlignment 设置单元格的垂直对齐类型
      */
-    public static void writeCellStyle(CellStyle cellStyle, short pattern, short backgroundColor,
-                                      short alignment, short verticalAlignment) {
+    public static void writeCellStyle(CellStyle cellStyle, FillPatternType pattern, short backgroundColor,
+                                      HorizontalAlignment alignment, VerticalAlignment verticalAlignment) {
         cellStyle.setFillPattern(pattern);
         cellStyle.setFillForegroundColor(backgroundColor);
         cellStyle.setAlignment(alignment);

+ 5 - 6
nationrel-module-alta-api/src/main/java/com/nationrel/modules/alta/util/ImportExcelUtil.java

@@ -3,7 +3,6 @@ package com.nationrel.modules.alta.util;
 import com.nationrel.modules.alta.constant.AltaConstants;
 import com.nationrel.modules.alta.general.domain.enums.reliaqube.ReliaqubeParamDataCheckEnum;
 import com.nationrel.modules.alta.general.exception.DescribeException;
-import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.util.NumberToTextConverter;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -91,10 +90,10 @@ public class ImportExcelUtil {
         DecimalFormat df2 = new DecimalFormat("0.00");  //格式化数字
 
         switch (cell.getCellType()) {
-            case Cell.CELL_TYPE_STRING:
+            case STRING:
                 value = cell.getRichStringCellValue().getString();
                 break;
-            case Cell.CELL_TYPE_NUMERIC:
+            case NUMERIC:
                 if ("General".equals(cell.getCellStyle().getDataFormatString())) {
                     value = NumberToTextConverter.toText(cell.getNumericCellValue()); // 解决精度丢失问题
                 } else if ("m/d/yy".equals(cell.getCellStyle().getDataFormatString())) {
@@ -103,10 +102,10 @@ public class ImportExcelUtil {
                     value = df2.format((int) cell.getNumericCellValue());
                 }
                 break;
-            case Cell.CELL_TYPE_BOOLEAN:
+            case BOOLEAN:
                 value = cell.getBooleanCellValue();
                 break;
-            case Cell.CELL_TYPE_BLANK:
+            case BLANK:
                 value = "";
                 break;
             default:
@@ -114,4 +113,4 @@ public class ImportExcelUtil {
         }
         return value;
     }
-}
+}