From ff851219a62f591eb84a05270f97ad5aa5ca259c Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Thu, 9 Apr 2020 16:58:17 +0800 Subject: [PATCH] =?UTF-8?q?*=20=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A81+?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84=E5=86=99=E6=B3=95=EF=BC=8C=E7=AC=AC?= =?UTF-8?q?1=E6=9D=A1=E5=BC=80=E5=A7=8B=E8=AF=BB=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E7=AC=AC0=E6=9D=A1=E5=BC=80=E5=A7=8B=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../java/com/alibaba/excel/ExcelReader.java | 2 ++ .../test/temp/read/HeadReadTest.java | 10 +++++++ .../test/temp/read/TestListener.java | 27 +++++++++++++++++++ update.md | 3 +++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/alibaba/easyexcel/test/temp/read/TestListener.java diff --git a/pom.xml b/pom.xml index fe46977f..c590f8f1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.alibaba easyexcel - 2.1.6 + 2.1.7 jar easyexcel diff --git a/src/main/java/com/alibaba/excel/ExcelReader.java b/src/main/java/com/alibaba/excel/ExcelReader.java index 07a373b7..39479e14 100644 --- a/src/main/java/com/alibaba/excel/ExcelReader.java +++ b/src/main/java/com/alibaba/excel/ExcelReader.java @@ -136,6 +136,8 @@ public class ExcelReader { readWorkbook.setReadCache(new MapCache()); readWorkbook.setConvertAllFiled(Boolean.FALSE); readWorkbook.setDefaultReturnMap(Boolean.FALSE); + // The previous logic was that Article 0 started reading + readWorkbook.setHeadRowNumber(0); excelAnalyser = new ExcelAnalyserImpl(readWorkbook); } diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java index b046d143..38eecb00 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java @@ -1,6 +1,7 @@ package com.alibaba.easyexcel.test.temp.read; import java.io.File; +import java.io.FileInputStream; import org.junit.Ignore; import org.junit.Test; @@ -8,7 +9,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; import com.alibaba.excel.cache.Ehcache; +import com.alibaba.excel.support.ExcelTypeEnum; /** * 临时测试 @@ -18,6 +21,13 @@ import com.alibaba.excel.cache.Ehcache; @Ignore public class HeadReadTest { private static final Logger LOGGER = LoggerFactory.getLogger(HeadReadTest.class); + @Test + public void testread() throws Exception { + FileInputStream fileInputStream = new FileInputStream("D://test/t1.xlsx"); + + ExcelReader excelReader = new ExcelReader(fileInputStream, ExcelTypeEnum.XLSX, null, new TestListener()); + excelReader.read(); + } @Test public void test() throws Exception { diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/read/TestListener.java b/src/test/java/com/alibaba/easyexcel/test/temp/read/TestListener.java new file mode 100644 index 00000000..fb80a9a4 --- /dev/null +++ b/src/test/java/com/alibaba/easyexcel/test/temp/read/TestListener.java @@ -0,0 +1,27 @@ +package com.alibaba.easyexcel.test.temp.read; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.fastjson.JSON; + +import lombok.extern.slf4j.Slf4j; + +/** + * TODO + * + * @author JiaJu Zhuang + * @date 2020/4/9 16:33 + **/ +@Slf4j +public class TestListener extends AnalysisEventListener { + + @Override + public void invoke(Object o, AnalysisContext analysisContext) { + log.info("解析一条:{}", JSON.toJSONString(o)); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + + } +} diff --git a/update.md b/update.md index 46258104..c1e4517d 100644 --- a/update.md +++ b/update.md @@ -1,3 +1,6 @@ +# 2.1.7 +* 修复使用1+版本的写法,第1条开始读修改为第0条开始读 + # 2.1.6 * 修复填充只有`sheetName`会抛异常