From 5be5c89210dbb626dbb87a81265ff8eef92979df Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期一, 15 十二月 2025 15:32:57 +0800
Subject: [PATCH] 修改了对应代码
---
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java | 48 ++++++++++++++++++++++++++++++++----------------
1 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
index a2bcb03..53de95f 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
@@ -604,21 +604,35 @@
style.setFont(dataFont);
styles.put("data", style);
- style = wb.createCellStyle();
- style.cloneStyleFrom(styles.get("data"));
- style.setAlignment(HorizontalAlignment.CENTER);
- style.setVerticalAlignment(VerticalAlignment.CENTER);
- // 璁剧疆鍗曞厓鏍煎唴瀹硅嚜鍔ㄦ崲琛�
- style.setWrapText(true);
- style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
- style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- Font headerFont = wb.createFont();
- headerFont.setFontName("Arial");
- headerFont.setFontHeightInPoints((short) 10);
- headerFont.setBold(true);
- headerFont.setColor(IndexedColors.WHITE.getIndex());
- style.setFont(headerFont);
- styles.put("header", style);
+ // 鍒涘缓琛ㄥご鏍峰紡鏄犲皠锛屾牴鎹瓻xcel娉ㄨВ鍔ㄦ�佺敓鎴�
+ Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>();
+ for (Object[] os : fields)
+ {
+ Excel excel = (Excel) os[1];
+ String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor());
+ if (!headerStyles.containsKey(key))
+ {
+ style = wb.createCellStyle();
+ style.cloneStyleFrom(styles.get("data"));
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+ // 璁剧疆鍗曞厓鏍煎唴瀹硅嚜鍔ㄦ崲琛�
+ style.setWrapText(true);
+ // 鏍规嵁娉ㄨВ璁剧疆琛ㄥご鑳屾櫙鑹� - 宸叉敞閲婏紝琛ㄥご涓嶆樉绀鸿儗鏅壊
+ /*if (excel.headerBackgroundColor() != IndexedColors.WHITE) {
+ style.setFillForegroundColor(excel.headerBackgroundColor().index);
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ }*/
+ Font headerFont = wb.createFont();
+ headerFont.setFontName("Arial");
+ headerFont.setFontHeightInPoints((short) 10);
+ headerFont.setBold(excel.headerFontBold());
+ headerFont.setColor(excel.headerColor().index);
+ style.setFont(headerFont);
+ headerStyles.put(key, style);
+ }
+ }
+ styles.putAll(headerStyles);
style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
@@ -664,7 +678,9 @@
// 鍐欏叆鍒椾俊鎭�
cell.setCellValue(attr.name());
setDataValidation(attr, row, column);
- cell.setCellStyle(styles.get("header"));
+ // 鏍规嵁Excel娉ㄨВ鍔ㄦ�侀�夋嫨琛ㄥご鏍峰紡
+ String key = StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor());
+ cell.setCellStyle(styles.get(key));
return cell;
}
--
Gitblit v1.9.1