From a1b615eb75cd958a64b2e62842739e01358e36b9 Mon Sep 17 00:00:00 2001 From: jipengfei-jpf <1558143046@qq.com> Date: Tue, 15 Oct 2019 17:55:47 +0800 Subject: [PATCH 1/2] Update README.md add contributes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 93ee3050..a04267e2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Java解析、生成Excel比较有名的框架有Apache poi、jxl。但他们都 * [English-README](/easyexcel_en.md) ## 维护者 -姬朋飞(玉霄) +玉霄、庄家钜、怀宇 ## 快速开始 ### 读Excel DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/src/test/java/com/alibaba/easyexcel/demo/read/ReadTest.java](/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java) @@ -86,4 +86,4 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/src/test/ja ### 联系我们 有问题阿里同事可以通过钉钉找到我,阿里外同学可以通过git留言。其他技术非技术相关的也欢迎一起探讨。 ### 招聘&交流 -阿里巴巴新零售事业部--诚招JAVA资深开发、技术专家。有意向可以微信联系,简历可以发我邮箱jipengfei.jpf@alibaba-inc.com \ No newline at end of file +阿里巴巴新零售事业部--诚招JAVA资深开发、技术专家。有意向可以微信联系,简历可以发我邮箱jipengfei.jpf@alibaba-inc.com From 3dc6f7a762d8a803f4ca1150a85a7fb3c6936c21 Mon Sep 17 00:00:00 2001 From: TangDH03 <315617683@qq.com> Date: Fri, 18 Oct 2019 12:02:56 +0800 Subject: [PATCH 2/2] ignore static final and transient --- .../excel/metadata/property/ExcelHeadProperty.java | 9 +++++++++ .../easyexcel/test/demo/write/ComplexHeadData.java | 2 ++ .../com/alibaba/easyexcel/test/demo/write/WriteTest.java | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java b/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java index a1200d5c..096d7d6c 100644 --- a/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java +++ b/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java @@ -1,6 +1,7 @@ package com.alibaba.excel.metadata.property; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -123,6 +124,14 @@ public class ExcelHeadProperty { Map customFiledMap = new TreeMap(); for (Field field : fieldList) { ExcelIgnore excelIgnore = field.getAnnotation(ExcelIgnore.class); + if(Modifier.isStatic(field.getModifiers())&&Modifier.isFinal(field.getModifiers())){ + ignoreMap.put(field.getName(),field); + continue; + } + if(Modifier.isTransient(field.getModifiers())){ + ignoreMap.put(field.getName(),field); + continue; + } if (excelIgnore != null) { ignoreMap.put(field.getName(), field); continue; diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/write/ComplexHeadData.java b/src/test/java/com/alibaba/easyexcel/test/demo/write/ComplexHeadData.java index 44ce5cc7..4c5d0c6b 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/write/ComplexHeadData.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/write/ComplexHeadData.java @@ -13,6 +13,8 @@ import lombok.Data; **/ @Data public class ComplexHeadData { + private final static String TITLE = "title"; + private transient String trans = "transient"; @ExcelProperty({"主标题", "字符串标题"}) private String string; @ExcelProperty({"主标题", "日期标题"}) diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java b/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java index 76c3c716..33420edf 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java @@ -85,7 +85,7 @@ public class WriteTest { *

* 2. 使用{@link ExcelProperty}注解指定复杂的头 *

- * 3. 直接写即可 + * 3. 直接写即可,写入时会忽略static final和 transient */ @Test public void complexHeadWrite() {