|
|
@ -4,22 +4,32 @@ import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
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.junit.Assert; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.context.AnalysisContext; |
|
|
|
|
|
|
|
import com.alibaba.excel.event.AnalysisEventListener; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author Jiaju Zhuang |
|
|
|
* @author Jiaju Zhuang |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ListHeadDataListener extends AnalysisEventListener<Map<Integer, String>> { |
|
|
|
public class ListHeadDataListener implements ReadListener<Map<Integer, String>> { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(NoHeadData.class); |
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(NoHeadData.class); |
|
|
|
List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>(); |
|
|
|
List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void invokeHead(Map<Integer, ReadCellData<?>> 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 |
|
|
|
@Override |
|
|
|
public void invoke(Map<Integer, String> data, AnalysisContext context) { |
|
|
|
public void invoke(Map<Integer, String> data, AnalysisContext context) { |
|
|
|
list.add(data); |
|
|
|
list.add(data); |
|
|
|