From e1bc4743f3b125718ebdf612355edc718d29e653 Mon Sep 17 00:00:00 2001 From: lethal233 <11811407@mail.sustech.edu.cn> Date: Thu, 20 May 2021 12:19:34 +0800 Subject: [PATCH] modify if-statement to satisfy pmd check --- .../alibaba/excel/write/property/ExcelWriteHeadProperty.java | 5 ++--- 1 file changed, 2 insertions(+), 3 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 2ba4ff9d..8e3cb45c 100644 --- a/src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java +++ b/src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java @@ -158,9 +158,8 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty { int lastCol = i; int lastRow = j; for (int k = i + 1; k < headList.size(); k++) { - if (headList.get(k).getHeadNameList().get(j).equals(headName) - && (j - 1 >= 0) - && !headList.get(k).getHeadNameList().get(j-1).equals(headName)) { + boolean flag = (j - 1 >= 0) && !headList.get(k).getHeadNameList().get(j - 1).equals(headName); + if (headList.get(k).getHeadNameList().get(j).equals(headName) && flag) { alreadyRangeSet.add(k + "-" + j); lastCol = k; } else {