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) + } } }