From e5630e09d9ff915de1212ed9f534df30c8d6f576 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Wed, 10 Nov 2021 17:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E6=96=B0=E5=A2=9Erowindex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/core/head/ListHeadDataListener.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/alibaba/easyexcel/test/core/head/ListHeadDataListener.java b/src/test/java/com/alibaba/easyexcel/test/core/head/ListHeadDataListener.java index c57976a9..58660c90 100644 --- a/src/test/java/com/alibaba/easyexcel/test/core/head/ListHeadDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/core/head/ListHeadDataListener.java @@ -4,22 +4,32 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.metadata.data.ReadCellData; +import com.alibaba.excel.read.listener.ReadListener; +import com.alibaba.fastjson.JSON; + import org.junit.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.alibaba.excel.context.AnalysisContext; -import com.alibaba.excel.event.AnalysisEventListener; -import com.alibaba.fastjson.JSON; - /** * @author Jiaju Zhuang */ -public class ListHeadDataListener extends AnalysisEventListener> { +public class ListHeadDataListener implements ReadListener> { private static final Logger LOGGER = LoggerFactory.getLogger(NoHeadData.class); List> list = new ArrayList>(); + @Override + public void invokeHead(Map> headMap, AnalysisContext context) { + Assert.assertNotNull(context.readRowHolder().getRowIndex()); + headMap.forEach((key, value) -> { + Assert.assertEquals(value.getRowIndex(), context.readRowHolder().getRowIndex()); + Assert.assertEquals(value.getColumnIndex(), key); + }); + } + @Override public void invoke(Map data, AnalysisContext context) { list.add(data);