|
@@ -1,11 +1,10 @@
|
|
package com.nationrel.modules.alta.util;
|
|
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.constant.AltaConstants;
|
|
|
|
+import com.nationrel.modules.alta.general.util.common.ValidateUtils;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
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 org.apache.poi.xssf.usermodel.*;
|
|
|
|
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
@@ -59,10 +58,10 @@ public class ExportExcelUtil {
|
|
//创建单元格,并设置值表头 设置表头居中
|
|
//创建单元格,并设置值表头 设置表头居中
|
|
XSSFCellStyle titleCellStyle = wb.createCellStyle();
|
|
XSSFCellStyle titleCellStyle = wb.createCellStyle();
|
|
XSSFCellStyle cellStyle = 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样式
|
|
// 设置:表头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);
|
|
fillSheet(sheet, list, fieldMap, titleCellStyle, cellStyle);
|
|
|
|
|
|
@@ -241,8 +240,8 @@ public class ExportExcelUtil {
|
|
* @param alignment 设置单元格的水平对齐类型
|
|
* @param alignment 设置单元格的水平对齐类型
|
|
* @param verticalAlignment 设置单元格的垂直对齐类型
|
|
* @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.setFillPattern(pattern);
|
|
cellStyle.setFillForegroundColor(backgroundColor);
|
|
cellStyle.setFillForegroundColor(backgroundColor);
|
|
cellStyle.setAlignment(alignment);
|
|
cellStyle.setAlignment(alignment);
|