From e576f6fec312a622820683d69166dcecc0da2717 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 16 May 2023 10:49:40 +0800 Subject: [PATCH 01/20] update parameter name --- .../main/java/com/alibaba/excel/util/ClassUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java index 92b828b4..d39abdc1 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java @@ -333,7 +333,7 @@ public class ClassUtils { return fieldCache; } // ignore filed - Map tempSortedFieldMapp = MapUtils.newHashMap(); + Map tempSortedFieldMap = MapUtils.newHashMap(); int index = 0; for (Map.Entry entry : sortedFieldMap.entrySet()) { Integer key = entry.getKey(); @@ -346,18 +346,18 @@ public class ClassUtils { } else { // Mandatory sorted fields if (indexFieldMap.containsKey(key)) { - tempSortedFieldMapp.put(key, field); + tempSortedFieldMap.put(key, field); } else { // Need to reorder automatically // Check whether the current key is already in use - while (tempSortedFieldMapp.containsKey(index)) { + while (tempSortedFieldMap.containsKey(index)) { index++; } - tempSortedFieldMapp.put(index++, field); + tempSortedFieldMap.put(index++, field); } } } - fieldCache.setSortedFieldMap(tempSortedFieldMapp); + fieldCache.setSortedFieldMap(tempSortedFieldMap); // resort field resortField(writeHolder, fieldCache); From b7dedeed1fa61821c7c0213a8161e969b04a01fa Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 16 May 2023 10:57:15 +0800 Subject: [PATCH 02/20] update comment --- .../src/main/java/com/alibaba/excel/util/ClassUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java index d39abdc1..f62d1ec9 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java @@ -65,7 +65,7 @@ public class ClassUtils { */ public static final ConcurrentHashMap, FieldCache> FIELD_CACHE = new ConcurrentHashMap<>(); /** - * thread local cahe + * thread local cache */ private static final ThreadLocal, FieldCache>> FIELD_THREAD_LOCAL = new ThreadLocal<>(); From 282dd8c237ea3265de04e66521a5830cc096db27 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 16 May 2023 11:25:41 +0800 Subject: [PATCH 03/20] update comment --- .../java/com/alibaba/excel/util/ClassUtils.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java index f62d1ec9..e1493763 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java @@ -36,6 +36,7 @@ import com.alibaba.excel.metadata.property.StyleProperty; import com.alibaba.excel.write.metadata.holder.WriteHolder; import lombok.AllArgsConstructor; +import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -49,7 +50,7 @@ import org.springframework.cglib.beans.BeanMap; * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -102,7 +103,8 @@ public class ClassUtils { * @return */ public static ExcelContentProperty declaredExcelContentProperty(Map dataMap, Class headClazz, - String fieldName, ConfigurationHolder configurationHolder) { + String fieldName, + ConfigurationHolder configurationHolder) { Class clazz = null; if (dataMap instanceof BeanMap) { Object bean = ((BeanMap)dataMap).getBean(); @@ -137,7 +139,8 @@ public class ClassUtils { } private static ExcelContentProperty doGetExcelContentProperty(Class clazz, Class headClass, - String fieldName, ConfigurationHolder configurationHolder) { + String fieldName, + ConfigurationHolder configurationHolder) { ExcelContentProperty excelContentProperty = Optional.ofNullable( declaredFieldContentMap(clazz, configurationHolder)) .map(map -> map.get(fieldName)) @@ -406,8 +409,8 @@ public class ClassUtils { // Index sorted map Map filedIndexMap = MapUtils.newHashMap(); int fieldIndex = 0; - for (Integer includeColumnIndexe : includeColumnIndexes) { - filedIndexMap.put(includeColumnIndexe, fieldIndex++); + for (Integer includeColumnIndex : includeColumnIndexes) { + filedIndexMap.put(includeColumnIndex, fieldIndex++); } // rebuild sortedFieldMap @@ -551,6 +554,7 @@ public class ClassUtils { private String fieldName; } + public static void removeThreadLocalCache() { FIELD_THREAD_LOCAL.remove(); CLASS_CONTENT_THREAD_LOCAL.remove(); From 67196ba295eee5dcae274d3dba48d1f45808b44c Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 16 May 2023 13:31:28 +0800 Subject: [PATCH 04/20] update cache --- .../com/alibaba/excel/util/ClassUtils.java | 27 +++++++++++++++---- .../easyexcel/test/demo/write/WriteTest.java | 18 ++++++++++++- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java index e1493763..d2ac7135 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java @@ -64,11 +64,11 @@ public class ClassUtils { /** * memory cache */ - public static final ConcurrentHashMap, FieldCache> FIELD_CACHE = new ConcurrentHashMap<>(); + public static final Map FIELD_CACHE = new ConcurrentHashMap<>(); /** * thread local cache */ - private static final ThreadLocal, FieldCache>> FIELD_THREAD_LOCAL = new ThreadLocal<>(); + private static final ThreadLocal> FIELD_THREAD_LOCAL = new ThreadLocal<>(); /** * The cache configuration information for each of the class @@ -280,16 +280,16 @@ public class ClassUtils { public static FieldCache declaredFields(Class clazz, ConfigurationHolder configurationHolder) { switch (configurationHolder.globalConfiguration().getFiledCacheLocation()) { case THREAD_LOCAL: - Map, FieldCache> fieldCacheMap = FIELD_THREAD_LOCAL.get(); + Map fieldCacheMap = FIELD_THREAD_LOCAL.get(); if (fieldCacheMap == null) { fieldCacheMap = MapUtils.newHashMap(); FIELD_THREAD_LOCAL.set(fieldCacheMap); } - return fieldCacheMap.computeIfAbsent(clazz, key -> { + return fieldCacheMap.computeIfAbsent(new FieldCacheKey(clazz, configurationHolder), key -> { return doDeclaredFields(clazz, configurationHolder); }); case MEMORY: - return FIELD_CACHE.computeIfAbsent(clazz, key -> { + return FIELD_CACHE.computeIfAbsent(new FieldCacheKey(clazz, configurationHolder), key -> { return doDeclaredFields(clazz, configurationHolder); }); case NONE: @@ -554,6 +554,23 @@ public class ClassUtils { private String fieldName; } + @Data + public static class FieldCacheKey { + private Class clazz; + private Collection excludeColumnFieldNames; + private Collection excludeColumnIndexes; + private Collection includeColumnFieldNames; + private Collection includeColumnIndexes; + + FieldCacheKey(Class clazz, ConfigurationHolder configurationHolder) { + this.clazz = clazz; + WriteHolder writeHolder = (WriteHolder)configurationHolder; + this.excludeColumnFieldNames = writeHolder.excludeColumnFieldNames(); + this.excludeColumnIndexes = writeHolder.excludeColumnIndexes(); + this.includeColumnFieldNames = writeHolder.includeColumnFieldNames(); + this.includeColumnIndexes = writeHolder.includeColumnIndexes(); + } + } public static void removeThreadLocalCache() { FIELD_THREAD_LOCAL.remove(); diff --git a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java index cd120e22..d224c1d6 100644 --- a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java +++ b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java @@ -4,11 +4,14 @@ import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; +import com.alibaba.easyexcel.test.core.head.ComplexHeadData; +import com.alibaba.easyexcel.test.demo.read.ConverterData; import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; @@ -409,7 +412,7 @@ public class WriteTest { /** * 列宽、行高 *

- * 1. 创建excel对应的实体对象 参照{@link WidthAndHeightData} + * 1. 创建excel对应的实体对象 参照{@link WidthAndHeightData } *

* 2. 使用注解{@link ColumnWidth}、{@link HeadRowHeight}、{@link ContentRowHeight}指定宽度或高度 *

@@ -703,6 +706,19 @@ public class WriteTest { EasyExcel.write(fileName).head(head()).sheet("模板").doWrite(dataList()); } + @Test + public void sheetCol(){ + String fileName = TestFileUtil.getPath() + "customCol" + System.currentTimeMillis() + ".xlsx"; + try (ExcelWriter excelWriter = EasyExcel.write(fileName, DemoData.class).includeColumnFieldNames(Arrays.asList("string","date","doubleData")).build()) { + // 把sheet设置为不需要头 不然会输出sheet的头 这样看起来第一个table 就有2个头了 + WriteSheet writeSheet = EasyExcel.writerSheet("模板").includeColumnFieldNames(Arrays.asList("string","date")).build(); + excelWriter.write(data(), writeSheet); + writeSheet = EasyExcel.writerSheet(1,"模板1").needHead(false).build(); + // 第二次写如也会创建头,然后在第一次的后面写入数据 + WriteTable string = EasyExcel.writerTable().needHead(true).includeColumnFieldNames(Arrays.asList("string")).build(); + excelWriter.write(data(),writeSheet,string); + } + } private List dataLong() { List list = ListUtils.newArrayList(); for (int i = 0; i < 10; i++) { From aef84b97f16c5bdae51a9e43f22223bf02aaa16e Mon Sep 17 00:00:00 2001 From: wuyiliang Date: Tue, 16 May 2023 19:46:23 +0800 Subject: [PATCH 05/20] [issue#3200]fix ClassCastException --- .../main/java/com/alibaba/excel/util/ClassUtils.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java index d2ac7135..f9a53e08 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java @@ -564,11 +564,13 @@ public class ClassUtils { FieldCacheKey(Class clazz, ConfigurationHolder configurationHolder) { this.clazz = clazz; - WriteHolder writeHolder = (WriteHolder)configurationHolder; - this.excludeColumnFieldNames = writeHolder.excludeColumnFieldNames(); - this.excludeColumnIndexes = writeHolder.excludeColumnIndexes(); - this.includeColumnFieldNames = writeHolder.includeColumnFieldNames(); - this.includeColumnIndexes = writeHolder.includeColumnIndexes(); + if (configurationHolder instanceof WriteHolder) { + WriteHolder writeHolder = (WriteHolder)configurationHolder; + this.excludeColumnFieldNames = writeHolder.excludeColumnFieldNames(); + this.excludeColumnIndexes = writeHolder.excludeColumnIndexes(); + this.includeColumnFieldNames = writeHolder.includeColumnFieldNames(); + this.includeColumnIndexes = writeHolder.includeColumnIndexes(); + } } } From a16b181c4ed56ce0672168194afd6b3bc0303caf Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 16 May 2023 22:19:21 +0800 Subject: [PATCH 06/20] fix class cast error --- .../com/alibaba/excel/util/ClassUtils.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java index d2ac7135..1447a078 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java @@ -1,20 +1,5 @@ package com.alibaba.excel.util; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentHashMap; - import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; @@ -34,7 +19,6 @@ import com.alibaba.excel.metadata.property.FontProperty; import com.alibaba.excel.metadata.property.NumberFormatProperty; import com.alibaba.excel.metadata.property.StyleProperty; import com.alibaba.excel.write.metadata.holder.WriteHolder; - import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -43,6 +27,11 @@ import lombok.Setter; import org.apache.commons.collections4.CollectionUtils; import org.springframework.cglib.beans.BeanMap; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -564,11 +553,13 @@ public class ClassUtils { FieldCacheKey(Class clazz, ConfigurationHolder configurationHolder) { this.clazz = clazz; - WriteHolder writeHolder = (WriteHolder)configurationHolder; - this.excludeColumnFieldNames = writeHolder.excludeColumnFieldNames(); - this.excludeColumnIndexes = writeHolder.excludeColumnIndexes(); - this.includeColumnFieldNames = writeHolder.includeColumnFieldNames(); - this.includeColumnIndexes = writeHolder.includeColumnIndexes(); + if (configurationHolder instanceof WriteHolder) { + WriteHolder writeHolder = (WriteHolder) configurationHolder; + this.excludeColumnFieldNames = writeHolder.excludeColumnFieldNames(); + this.excludeColumnIndexes = writeHolder.excludeColumnIndexes(); + this.includeColumnFieldNames = writeHolder.includeColumnFieldNames(); + this.includeColumnIndexes = writeHolder.includeColumnIndexes(); + } } } From 90dd2f4e3d8de59f841062c51cf97508996d6f0e Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Fri, 19 May 2023 15:04:19 +0800 Subject: [PATCH 07/20] update write test import package --- .../java/com/alibaba/easyexcel/test/demo/write/WriteTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java index d224c1d6..990f2630 100644 --- a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java +++ b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java @@ -11,7 +11,6 @@ import java.util.List; import java.util.Set; import com.alibaba.easyexcel.test.core.head.ComplexHeadData; -import com.alibaba.easyexcel.test.demo.read.ConverterData; import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; From 2ac224c70f6a2471ed1e9796a42b1d0d8d897a71 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Thu, 25 May 2023 09:21:20 +0800 Subject: [PATCH 08/20] =?UTF-8?q?=E5=8A=A0=E7=BE=A4=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 90b10c07..fbee1f4c 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,8 @@ easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析 [钉钉7群(已满): 35235427](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=ding532b9018c06c7fc8660273c4b78e6440&167fb=ed003&cbdbhh=qwertyuiop) [钉钉8群(已满): 44752220](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=dingea96808beee421693fd4ba7542d6e5da&0380092a-fa46=a6a40905-7951&cbdbhh=qwertyuiop) [钉钉9群(已满): 11045002277](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=dinge338d2215891c0459c13cd6b2cb108a6&6972d=b92f9&cbdbhh=qwertyuiop) -[钉钉10群: 27360019755](https://qr.dingtalk.com/action/joingroup?code=v1,k1,v25LHn2liWmrWUKlkhIzOTcK7s7onp/sZP8mO5oIYSs=&_dt_no_comment=1&origin=11) +[钉钉10群(已满): 27360019755](https://qr.dingtalk.com/action/joingroup?code=v1,k1,v25LHn2liWmrWUKlkhIzOTcK7s7onp/sZP8mO5oIYSs=&_dt_no_comment=1&origin=11) +[钉钉11群:24330026964](https://qr.dingtalk.com/action/joingroup?code=v1,k1,63PjvTncu81oQ3X6XmGEJqnwQHCQxi/jaVlbUStq79o=&_dt_no_comment=1&origin=11) # 维护者 From bf2c31cd7c65fdc562e4623740dec4dc117a794f Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Tue, 30 May 2023 14:33:46 +0800 Subject: [PATCH 09/20] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=A1=88=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExcludeOrIncludeDataTest.java | 43 ++++++++----------- .../easyexcel/test/demo/write/WriteTest.java | 13 ------ 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/excludeorinclude/ExcludeOrIncludeDataTest.java b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/excludeorinclude/ExcludeOrIncludeDataTest.java index 31244e15..314b5de4 100644 --- a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/excludeorinclude/ExcludeOrIncludeDataTest.java +++ b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/excludeorinclude/ExcludeOrIncludeDataTest.java @@ -1,20 +1,11 @@ package com.alibaba.easyexcel.test.core.excludeorinclude; -import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.excel.EasyExcel; +import org.junit.jupiter.api.*; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; +import java.io.File; +import java.util.*; /** * @author Jiaju Zhuang @@ -159,7 +150,7 @@ public class ExcludeOrIncludeDataTest { excludeColumnIndexes.add(0); excludeColumnIndexes.add(3); EasyExcel.write(file, ExcludeOrIncludeData.class).excludeColumnIndexes(excludeColumnIndexes).sheet() - .doWrite(data()); + .doWrite(data()); List> dataMap = EasyExcel.read(file).sheet().doReadSync(); Assertions.assertEquals(1, dataMap.size()); Map record = dataMap.get(0); @@ -175,7 +166,7 @@ public class ExcludeOrIncludeDataTest { excludeColumnFieldNames.add("column3"); excludeColumnFieldNames.add("column4"); EasyExcel.write(file, ExcludeOrIncludeData.class).excludeColumnFieldNames(excludeColumnFieldNames).sheet() - .doWrite(data()); + .doWrite(data()); List> dataMap = EasyExcel.read(file).sheet().doReadSync(); Assertions.assertEquals(1, dataMap.size()); Map record = dataMap.get(0); @@ -189,7 +180,7 @@ public class ExcludeOrIncludeDataTest { includeColumnIndexes.add(1); includeColumnIndexes.add(2); EasyExcel.write(file, ExcludeOrIncludeData.class).includeColumnIndexes(includeColumnIndexes).sheet() - .doWrite(data()); + .doWrite(data()); List> dataMap = EasyExcel.read(file).sheet().doReadSync(); Assertions.assertEquals(1, dataMap.size()); Map record = dataMap.get(0); @@ -203,8 +194,10 @@ public class ExcludeOrIncludeDataTest { Set includeColumnFieldNames = new HashSet(); includeColumnFieldNames.add("column2"); includeColumnFieldNames.add("column3"); - EasyExcel.write(file, ExcludeOrIncludeData.class).includeColumnFieldNames(includeColumnFieldNames).sheet() - .doWrite(data()); + EasyExcel.write(file, ExcludeOrIncludeData.class) + .sheet() + .includeColumnFieldNames(includeColumnFieldNames) + .doWrite(data()); List> dataMap = EasyExcel.read(file).sheet().doReadSync(); Assertions.assertEquals(1, dataMap.size()); Map record = dataMap.get(0); @@ -220,10 +213,10 @@ public class ExcludeOrIncludeDataTest { includeColumnIndexes.add(2); includeColumnIndexes.add(0); EasyExcel.write(file, ExcludeOrIncludeData.class) - .includeColumnIndexes(includeColumnIndexes) - .orderByIncludeColumn(true). - sheet() - .doWrite(data()); + .includeColumnIndexes(includeColumnIndexes) + .orderByIncludeColumn(true). + sheet() + .doWrite(data()); List> dataMap = EasyExcel.read(file).sheet().doReadSync(); Assertions.assertEquals(1, dataMap.size()); Map record = dataMap.get(0); @@ -240,10 +233,10 @@ public class ExcludeOrIncludeDataTest { includeColumnFieldNames.add("column2"); includeColumnFieldNames.add("column3"); EasyExcel.write(file, ExcludeOrIncludeData.class) - .includeColumnFieldNames(includeColumnFieldNames) - .orderByIncludeColumn(true). - sheet() - .doWrite(data()); + .includeColumnFieldNames(includeColumnFieldNames) + .orderByIncludeColumn(true). + sheet() + .doWrite(data()); List> dataMap = EasyExcel.read(file).sheet().doReadSync(); Assertions.assertEquals(1, dataMap.size()); Map record = dataMap.get(0); diff --git a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java index 990f2630..0e7cf2db 100644 --- a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java +++ b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java @@ -705,19 +705,6 @@ public class WriteTest { EasyExcel.write(fileName).head(head()).sheet("模板").doWrite(dataList()); } - @Test - public void sheetCol(){ - String fileName = TestFileUtil.getPath() + "customCol" + System.currentTimeMillis() + ".xlsx"; - try (ExcelWriter excelWriter = EasyExcel.write(fileName, DemoData.class).includeColumnFieldNames(Arrays.asList("string","date","doubleData")).build()) { - // 把sheet设置为不需要头 不然会输出sheet的头 这样看起来第一个table 就有2个头了 - WriteSheet writeSheet = EasyExcel.writerSheet("模板").includeColumnFieldNames(Arrays.asList("string","date")).build(); - excelWriter.write(data(), writeSheet); - writeSheet = EasyExcel.writerSheet(1,"模板1").needHead(false).build(); - // 第二次写如也会创建头,然后在第一次的后面写入数据 - WriteTable string = EasyExcel.writerTable().needHead(true).includeColumnFieldNames(Arrays.asList("string")).build(); - excelWriter.write(data(),writeSheet,string); - } - } private List dataLong() { List list = ListUtils.newArrayList(); for (int i = 0; i < 10; i++) { From 63cda6ce9fa8f72398b52581b8f3960fe6e7912c Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Tue, 30 May 2023 14:34:44 +0800 Subject: [PATCH 10/20] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=A1=88=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- update.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fbee1f4c..b53f44a6 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析 com.alibaba easyexcel - 3.3.1 + 3.3.2 ``` diff --git a/update.md b/update.md index 3b0b4e95..3000935f 100644 --- a/update.md +++ b/update.md @@ -1,5 +1,9 @@ # 3.3.1 +* 修复`includeColumnIndexes`和`includeColumnFieldNames`在sheet后面失效的问题 + +# 3.3.1 + * 修改版本发布问题 # 3.3.0 From 573f55ba82b8e4f1e2d6a5c35e7ac17685adc4ca Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Tue, 30 May 2023 14:44:59 +0800 Subject: [PATCH 11/20] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=A1=88=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.md b/update.md index 3000935f..c448d238 100644 --- a/update.md +++ b/update.md @@ -1,4 +1,4 @@ -# 3.3.1 +# 3.3.2 * 修复`includeColumnIndexes`和`includeColumnFieldNames`在sheet后面失效的问题 From de4e5364d1eedec8616cb8d6c3f7927266ccd165 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Tue, 30 May 2023 14:57:03 +0800 Subject: [PATCH 12/20] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 926c91bd..9ed5cafb 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ - 3.3.1 + 3.3.2 UTF-8 1.8 true From 304994808bf551d2d0fc93abfc61e68ccf863215 Mon Sep 17 00:00:00 2001 From: jipengfei-jpf <1558143046@qq.com> Date: Tue, 6 Jun 2023 11:02:57 +0800 Subject: [PATCH 13/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b53f44a6..801490be 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 🔥作者最新开源项目[Chat2DB](https://github.com/alibaba/Chat2DB) -[Chat2DB](https://github.com/alibaba/Chat2DB) 智能数据库客户端,比Navicat、DataGrip更智能,体验更好,永久免费无需破解。 GitHub地址 [https://github.com/alibaba/Chat2DB](https://github.com/alibaba/Chat2DB) +[Chat2DB](https://github.com/alibaba/Chat2DB) 智能数据库客户端,数据报表工具,自然语言生成SQL,生成报表。 GitHub地址 [https://github.com/alibaba/Chat2DB](https://github.com/alibaba/Chat2DB) EasyExcel ====================== From 3a3493b80e26d6b6766debb267db409dd4e536d5 Mon Sep 17 00:00:00 2001 From: aobing <1044103023@qq.com> Date: Tue, 20 Jun 2023 22:14:27 +0800 Subject: [PATCH 14/20] add info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 801490be..7d2bc4d2 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析 # 维护者 -姬朋飞(玉霄)、庄家钜、怀宇 +姬朋飞(玉霄)、庄家钜、怀宇、敖丙 # 快速开始 From 8d5fbec12e80814a73f45748f1d19a9e46aa6432 Mon Sep 17 00:00:00 2001 From: jipengfei-jpf <1558143046@qq.com> Date: Wed, 21 Jun 2023 01:25:53 +0800 Subject: [PATCH 15/20] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d2bc4d2..159237b1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# 🔥作者最新开源项目[Chat2DB](https://github.com/alibaba/Chat2DB) -[Chat2DB](https://github.com/alibaba/Chat2DB) 智能数据库客户端,数据报表工具,自然语言生成SQL,生成报表。 GitHub地址 [https://github.com/alibaba/Chat2DB](https://github.com/alibaba/Chat2DB) +# 🔥作者最新开源项目[Chat2DB](https://github.com/chat2db/Chat2DB) +[Chat2DB](https://github.com/chat2db/Chat2DB) 智能数据库客户端,数据报表工具,自然语言生成SQL,生成报表。 GitHub地址 [https://github.com/alibaba/Chat2DB](https://github.com/chat2db/Chat2DB) EasyExcel ====================== From b1bfe73726848328ce7443b43a0b69ea1d4c6a86 Mon Sep 17 00:00:00 2001 From: jipengfei-jpf <1558143046@qq.com> Date: Wed, 21 Jun 2023 01:26:23 +0800 Subject: [PATCH 16/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 159237b1..1eed607e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 🔥作者最新开源项目[Chat2DB](https://github.com/chat2db/Chat2DB) -[Chat2DB](https://github.com/chat2db/Chat2DB) 智能数据库客户端,数据报表工具,自然语言生成SQL,生成报表。 GitHub地址 [https://github.com/alibaba/Chat2DB](https://github.com/chat2db/Chat2DB) +[Chat2DB](https://github.com/chat2db/Chat2DB) 智能数据库客户端,数据报表工具,自然语言生成SQL,生成报表。 GitHub地址 [https://github.com/alibaba/chat2db](https://github.com/chat2db/Chat2DB) EasyExcel ====================== From bb7b3a2d380433bb48f31b3d383d2854e06d6bef Mon Sep 17 00:00:00 2001 From: jipengfei-jpf <1558143046@qq.com> Date: Mon, 26 Jun 2023 23:32:41 +0800 Subject: [PATCH 17/20] Update README.md --- README.md | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 1eed607e..035d49f9 100644 --- a/README.md +++ b/README.md @@ -88,25 +88,9 @@ easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析 ## 也可以加入钉钉&QQ群来解决问题 -加入钉钉或QQ群,看完公告可以获得帮助 。 -比较推荐钉钉群,`QQ` 公司不让用,当然QQ群也会有热心网友帮忙解决。 -[QQ1群(已满): 662022184](https://jq.qq.com/?_wv=1027&k=1T21jJxh) -[QQ2群(已满): 1097936804](https://jq.qq.com/?_wv=1027&k=j5zEy6Xl) -[QQ3群(已满): 453928496](https://qm.qq.com/cgi-bin/qm/qr?k=e2ULsA5A0GldhV2CXJ8sIbAyu9I6qqs7&jump_from=webapi) -[QQ4群(已满): 496594404](https://qm.qq.com/cgi-bin/qm/qr?k=e_aVG1Q7gi0PJUBkbrUGAgbeO3kUEInK&jump_from=webapi) -[QQ5群(已满): 451925680](https://jq.qq.com/?_wv=1027&k=6VHhvxyf) -[QQ6群: 784741035](https://jq.qq.com/?_wv=1027&k=BbLBIo9P) -[钉钉1群(已满): 21960511](https://qr.dingtalk.com/action/joingroup?code=v1,k1,cchz6k12ci9B08NNqhNRFGXocNVHrZtW0kaOtTKg/Rk=&_dt_no_comment=1&origin=11) -[钉钉2群(已满): 32796397](https://qr.dingtalk.com/action/joingroup?code=v1,k1,jyU9GtEuNU5S0QTyklqYcYJ8qDZtUuTPMM7uPZTS8Hs=&_dt_no_comment=1&origin=11) -[钉钉3群(已满): 33797247](https://qr.dingtalk.com/action/joingroup?code=v1,k1,3UGlEScTGQaHpW2cIRo+gkxJ9EVZ5fz26M6nW3uFP30=&_dt_no_comment=1&origin=11) -[钉钉4群(已满): 33491624](https://qr.dingtalk.com/action/joingroup?code=v1,k1,V14Pb65Too70rQkEaJ9ohb6lZBZbtp6jIL/q9EWh9vA=&_dt_no_comment=1&origin=11) -[钉钉5群(已满): 32134498](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=dingb9fa1325d9dccc3ecac589edd02f1650&5233a=71a83&cbdbhh=qwertyuiop) -[钉钉6群(已满): 34707941](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=dingcf68008a1d443ac012d5427bdb061b7a&6ae36c3d-0c80-4=22398493-6c2a-4&cbdbhh=qwertyuiop) -[钉钉7群(已满): 35235427](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=ding532b9018c06c7fc8660273c4b78e6440&167fb=ed003&cbdbhh=qwertyuiop) -[钉钉8群(已满): 44752220](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=dingea96808beee421693fd4ba7542d6e5da&0380092a-fa46=a6a40905-7951&cbdbhh=qwertyuiop) -[钉钉9群(已满): 11045002277](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=dinge338d2215891c0459c13cd6b2cb108a6&6972d=b92f9&cbdbhh=qwertyuiop) -[钉钉10群(已满): 27360019755](https://qr.dingtalk.com/action/joingroup?code=v1,k1,v25LHn2liWmrWUKlkhIzOTcK7s7onp/sZP8mO5oIYSs=&_dt_no_comment=1&origin=11) -[钉钉11群:24330026964](https://qr.dingtalk.com/action/joingroup?code=v1,k1,63PjvTncu81oQ3X6XmGEJqnwQHCQxi/jaVlbUStq79o=&_dt_no_comment=1&origin=11) +关注微信公众号(Text2SQL)回复 "群" or "加群" 加入微信群、钉钉群、QQ群探讨问题 + + # 维护者 From 0c640f6c7e86c8eef3f747699f748a9e378367cf Mon Sep 17 00:00:00 2001 From: jipengfei-jpf <1558143046@qq.com> Date: Mon, 26 Jun 2023 23:33:04 +0800 Subject: [PATCH 18/20] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 035d49f9..e978862c 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析 ## 也可以加入钉钉&QQ群来解决问题 关注微信公众号(Text2SQL)回复 "群" or "加群" 加入微信群、钉钉群、QQ群探讨问题 + From 259d3031681ad1806f28f4bc4cdd4fbcbf503f74 Mon Sep 17 00:00:00 2001 From: wangxin <269481826@qq.com> Date: Tue, 11 Jul 2023 17:45:36 +0800 Subject: [PATCH 19/20] fix bug:the log of ReadTest.simpleRead do not work --- easyexcel-test/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/easyexcel-test/pom.xml b/easyexcel-test/pom.xml index 840d3f61..3174f4f0 100644 --- a/easyexcel-test/pom.xml +++ b/easyexcel-test/pom.xml @@ -42,6 +42,11 @@ + + org.slf4j + slf4j-simple + 1.7.36 + org.slf4j jcl-over-slf4j From 857453f245cc5b69d8e39172e3a6a7496ae3ac91 Mon Sep 17 00:00:00 2001 From: jipengfei-jpf <1558143046@qq.com> Date: Thu, 20 Jul 2023 20:43:15 +0800 Subject: [PATCH 20/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e978862c..3438bc5d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 🔥作者最新开源项目[Chat2DB](https://github.com/chat2db/Chat2DB) -[Chat2DB](https://github.com/chat2db/Chat2DB) 智能数据库客户端,数据报表工具,自然语言生成SQL,生成报表。 GitHub地址 [https://github.com/alibaba/chat2db](https://github.com/chat2db/Chat2DB) +[Chat2DB](https://github.com/chat2db/Chat2DB) 智能数据库客户端,数据报表工具,自然语言生成SQL,生成报表。 GitHub地址 [https://github.com/chat2db/chat2db](https://github.com/chat2db/Chat2DB) EasyExcel ======================