From b4545debd1460ac10c162dc1477b730d846a6e91 Mon Sep 17 00:00:00 2001 From: smireg <402809775@qq.com> Date: Sun, 18 Apr 2021 18:24:05 +0800 Subject: [PATCH] bugfix1765 --- .../property/ExcelWriteHeadProperty.java | 4 +- .../test/demo/Test1765/Data1765.xlsx | Bin 0 -> 3687 bytes .../test/demo/Test1765/Issue1765.java | 55 ++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 src/test/java/com/alibaba/easyexcel/test/demo/Test1765/Data1765.xlsx create mode 100644 src/test/java/com/alibaba/easyexcel/test/demo/Test1765/Issue1765.java 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 979a7750..aa4893e5 100644 --- a/src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java +++ b/src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java @@ -154,11 +154,11 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty { continue; } alreadyRangeSet.add(i + "-" + j); - String headName = headNameList.get(j); + String headName = headNameList.get(j) == null ? "" : headNameList.get(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)) { + if ((headList.get(k).getHeadNameList().get(j) == null ? "" : headList.get(k).getHeadNameList().get(j)).equals(headName)) { alreadyRangeSet.add(k + "-" + j); lastCol = k; } else { diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/Test1765/Data1765.xlsx b/src/test/java/com/alibaba/easyexcel/test/demo/Test1765/Data1765.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..3377bb760f7a27ff706a43fda2d77dd6dd323ab7 GIT binary patch literal 3687 zcmaJ^2{@GP8XoHyd)cGx#NW@z7Lx2EYeI~&jb&^z43cfEjmVm{NMQ(3$iDuA(jdQ` zi0n&6b|cA|sdIjgbL#o7Z@!u9dY^Zm=YH?+e(%>vmx7WN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AY#e0e0mKc27eNW!SCU%p zPRKX?5Iq|UnRo!v&02925Ebxa@7KmU`@l5UwS^A!gnWOFRgpT~MI0OX_Q9JPu2u=L zwrUMF)3Mw~15mlrJHx}PW+<^rBav{X+K8J6sRIJTt$)T0c+N4FrH(gSy)65H7F)9> z5l4A(==28hg~CviWQUBL6>xYaIO>Q=XM+EZBPWF8iAU`m$uJ)V5Am=5k9|Hq!BP7} za(#!9P9*qo4|qKLsBs`!tiy1oIFkJz!*x9U=;lpw7l%=11}`RPp#cM@d1_jKg>b`lpEh YQ4k|tDk6yh01)v~AuiKNdeX0d0kp*88vp> head() { + List> list = new ArrayList>(); + List head0 = new ArrayList(); + List head1 = new ArrayList(); + List head2 = new ArrayList(); + List head3 = new ArrayList(); + head0.add("表头"); + head1.add("日期"); + head2.add(null); + head3.add("数字"); + list.add(head0); + list.add(head1); + list.add(head2); + list.add(head3); + + return list; + } + + private List> dataList() { + List> list = new ArrayList>(); + for (int i = 0; i < 5; i++) { + List data = new ArrayList(); + data.add("字符串" + i); + data.add(new Date()); + data.add(i * 2); + data.add(i * 3); + list.add(data); + } + return list; + } +}