From df761896987ab03be0a4b15d01f26651278cd9b2 Mon Sep 17 00:00:00 2001 From: zhuangjiaju Date: Tue, 6 Aug 2019 10:04:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=BB=E5=86=99=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../write/property/ExcelWriteHeadProperty.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java b/src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java index b4d43e1..8d05424 100644 --- a/src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java +++ b/src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java @@ -86,12 +86,12 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty { } alreadyRangeSet.add(i + "-" + j); String headName = headNameList.get(j); - int endX = i; - int endY = j; + int lastCol = i; + int lastRow = j; for (int k = i + 1; k < headList.size(); k++) { if (headList.get(k).getHeadNameList().get(j).equals(headName)) { alreadyRangeSet.add(k + "-" + j); - endX = k; + lastCol = k; } else { break; } @@ -99,20 +99,20 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty { Set tempAlreadyRangeSet = new HashSet(); outer: for (int k = j + 1; k < headNameList.size(); k++) { - for (int l = i; l <= endX; l++) { + for (int l = i; l <= lastCol; l++) { if (headList.get(l).getHeadNameList().get(k).equals(headName)) { tempAlreadyRangeSet.add(l + "-" + k); } else { break outer; } } - endY = k; + lastRow = k; alreadyRangeSet.addAll(tempAlreadyRangeSet); } - if (j == endY && i == endX) { + if (j == lastRow && i == lastCol) { continue; } - cellRangeList.add(new CellRange(j, endY, i, endX)); + cellRangeList.add(new CellRange(j, lastRow, i, lastCol)); } } return cellRangeList;