From c86686ac950363dfc582207968c3828fd43b6f88 Mon Sep 17 00:00:00 2001 From: wisonic Date: Fri, 16 Jan 2026 17:56:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E8=A1=A8=E5=BC=80=E5=90=AF=E8=A1=A8=E5=A4=B4=E5=88=86=E7=BB=84?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=8D=95=E5=85=83=E6=A0=BC=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=20Excel=20=E4=BC=9A=E5=AF=BC=E8=87=B4=E7=BA=BF?= =?UTF-8?q?=E6=9D=A1=E7=BC=BA=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/chart/server/ChartDataServer.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java b/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java index e76eac524b..b4d6098828 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java +++ b/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java @@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.RegionUtil; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestMapping; @@ -661,9 +662,9 @@ public class ChartDataServer implements ChartDataApi { } } - private static void createCell(TableHeader tableHeader, TableHeader.ColumnInfo column, Integer width, Integer depth, Sheet sheet, CellStyle cellStyle, Integer totaalDepth, Map rowMap, List xAxis) { + private static void createCell(TableHeader tableHeader, TableHeader.ColumnInfo column, Integer width, Integer depth, Sheet sheet, CellStyle cellStyle, Integer totalDepth, Map rowMap, List xAxis) { if (org.springframework.util.CollectionUtils.isEmpty(column.getChildren())) { - Integer toDepth = totaalDepth - 1 > depth ? totaalDepth - 1 : depth; + Integer toDepth = totalDepth - 1 > depth ? totalDepth - 1 : depth; if (depth.equals(toDepth)) { Cell cell = rowMap.get("row" + depth).createCell(width); cell.setCellStyle(cellStyle); @@ -676,7 +677,10 @@ public class ChartDataServer implements ChartDataApi { } CellRangeAddress region = new CellRangeAddress(depth, toDepth, width, width); sheet.addMergedRegion(region); - + RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet); Cell mergedCell = rowMap.get("row" + depth).getCell(width); mergedCell.setCellStyle(cellStyle); @@ -690,11 +694,15 @@ public class ChartDataServer implements ChartDataApi { cell2.setCellStyle(cellStyle); CellRangeAddress region = new CellRangeAddress(depth, depth, width, width + column.getWidth() - 1); sheet.addMergedRegion(region); + RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet); Cell mergedCell = rowMap.get("row" + depth).getCell(width); mergedCell.setCellStyle(cellStyle); int subWith = width; for (TableHeader.ColumnInfo child : column.getChildren()) { - createCell(tableHeader, child, subWith, depth + 1, sheet, cellStyle, totaalDepth, rowMap, xAxis); + createCell(tableHeader, child, subWith, depth + 1, sheet, cellStyle, totalDepth, rowMap, xAxis); subWith = subWith + child.getWidth(); } }