From b200a67474c0cde5fe8d6ce7dd4d604675de2129 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 12 九月 2025 17:08:20 +0800
Subject: [PATCH] 最新版本541200007
---
server/system_service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java | 56 +++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/server/system_service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java b/server/system_service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
index 0b02a91..05624af 100644
--- a/server/system_service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
+++ b/server/system_service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
@@ -440,26 +440,28 @@
Sheet sheet = sxssfWorkbook.createSheet(sheetName);
// 鍒涘缓鍒楀ご
sheet.createFreezePane(0, 1);
- Row header = sheet.createRow(0);
CellStyle hstyle = configHeaderCellStatic(sxssfWorkbook);
+ CellStyle rowStyle = configDataCellStatic(sxssfWorkbook);
for (int i = 0; i < dataList.size(); i++) {
- Cell cell = header.createCell(i);
- cell.setCellValue(dataList.get(i).get(Constants.ZERO));
- // 鍒楀璁剧疆
- sheet.setColumnWidth(i, dataList.get(i).get(Constants.ZERO).length() * 2 * 256);
- // 璁剧疆鍒楀ご鍗曞厓鏍�
- cell.setCellStyle(hstyle);
- }
-
- //鎬昏鏁�
- Integer rowSize = dataList.get(Constants.ZERO).size();
- //鎬诲垪鏁�
- Integer columnSize = dataList.size();
- for (int i = 1; i < rowSize; i++) {
Row row = sheet.createRow(i);
- for (int j = 0; j < columnSize; j++) {
+ List<String> rowList = dataList.get(i);
+ for (int j = 0; j < rowList.size(); j++) {
Cell cell = row.createCell(j);
- cell.setCellValue(dataList.get(j).get(i));
+ cell.setCellValue(rowList.get(j));
+// if(i==0&&j==0){
+// cell.setCellValue("鏁版嵁鏃ユ湡");
+// }else{
+// cell.setCellValue(rowList.get(j));
+// }
+ if(i==0){
+ sheet.setColumnWidth(i, (rowList.get(j).length() + 2 ) * 2 * 256);
+// cell.setCellStyle(hstyle);
+ }
+ if(i==0 || j==0){
+ cell.setCellStyle(hstyle);
+ }else{
+ cell.setCellStyle(rowStyle);
+ }
}
}
sxssfWorkbook.write(os);
@@ -477,6 +479,7 @@
}
}
+
private static CellStyle configHeaderCellStatic (SXSSFWorkbook workbook) {
CellStyle style = workbook.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
@@ -486,7 +489,7 @@
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
// 瀛椾綋
Font font = workbook.createFont();
- font.setFontHeightInPoints((short) 12);
+ font.setFontHeightInPoints((short) 10);
style.setFont(font);
// 璁剧疆杈规
configCellBorder(style);
@@ -494,6 +497,25 @@
}
+ /**
+ * 閰嶇疆鏁版嵁鍗曞厓鏍�
+ */
+ private static CellStyle configDataCellStatic (SXSSFWorkbook workbook ) {
+ CellStyle configDataCellStyle = workbook.createCellStyle();
+ configDataCellStyle.setAlignment(HorizontalAlignment.CENTER);
+ configDataCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+ // 璁剧疆鑳屾櫙
+// configDataCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+// configDataCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+ // 瀛椾綋
+ Font font = workbook.createFont();
+ font.setFontHeightInPoints((short) 10);
+ configDataCellStyle.setFont(font);
+ // 杈规
+ configCellBorder(configDataCellStyle);
+ configDataCellStyle.setWrapText(true);
+ return configDataCellStyle;
+ }
}
--
Gitblit v1.9.3