From 5574322e649f8d30250328d00b1897c532cde34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Wed, 7 Jul 2021 14:05:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dexcel=E5=90=88=E5=B9=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../groovy/com/fangjia/script/util/ExcelUtils.groovy | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ExcelUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ExcelUtils.groovy index 203508a51..cc026d9fc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ExcelUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ExcelUtils.groovy @@ -346,11 +346,13 @@ public class ExcelUtils{ mergedCellStyle.alignment = HorizontalAlignment.CENTER; for (List rowCell : data) { - CellRangeAddress cra = new CellRangeAddress(rowCell.get(0), rowCell.get(1), rowCell.get(2), rowCell.get(3)) - sheet.addMergedRegion(cra); - //设置合并后style - def cell = sheet.getRow(rowCell.get(0)).getCell(rowCell.get(2)); - cell.setCellStyle(mergedCellStyle) + if (rowCell.get(0) != rowCell.get(1)) { + CellRangeAddress cra = new CellRangeAddress(rowCell.get(0), rowCell.get(1), rowCell.get(2), rowCell.get(3)) + sheet.addMergedRegion(cra); + //设置合并后style + def cell = sheet.getRow(rowCell.get(0)).getCell(rowCell.get(2)); + cell.setCellStyle(mergedCellStyle) + } } }