|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package com.alibaba.excel.read.processor; |
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Method; |
|
|
|
|
import java.text.DateFormat; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
@ -10,6 +12,7 @@ import com.alibaba.excel.enums.RowTypeEnum;
|
|
|
|
|
import com.alibaba.excel.exception.ExcelAnalysisException; |
|
|
|
|
import com.alibaba.excel.exception.ExcelAnalysisStopException; |
|
|
|
|
import com.alibaba.excel.metadata.Head; |
|
|
|
|
import com.alibaba.excel.metadata.data.DataFormatData; |
|
|
|
|
import com.alibaba.excel.metadata.data.ReadCellData; |
|
|
|
|
import com.alibaba.excel.read.listener.ReadListener; |
|
|
|
|
import com.alibaba.excel.read.metadata.holder.ReadRowHolder; |
|
|
|
@ -79,6 +82,8 @@ public class DefaultAnalysisEventProcessor implements AnalysisEventProcessor {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void dealData(AnalysisContext analysisContext) { |
|
|
|
|
ReadRowHolder readRowHolder = analysisContext.readRowHolder(); |
|
|
|
|
Map<Integer, ReadCellData<?>> cellDataMap = (Map)readRowHolder.getCellMap(); |
|
|
|
@ -97,6 +102,22 @@ public class DefaultAnalysisEventProcessor implements AnalysisEventProcessor {
|
|
|
|
|
try { |
|
|
|
|
if (isData) { |
|
|
|
|
readListener.invoke(readRowHolder.getCurrentRowAnalysisResult(), analysisContext); |
|
|
|
|
Class c=readRowHolder.getCurrentRowAnalysisResult().getClass(); |
|
|
|
|
Method[] methods=c.getMethods(); |
|
|
|
|
String date=""; |
|
|
|
|
for (int i = 0; i < methods.length; i++) { |
|
|
|
|
if (methods[i].equals(c.getMethod("getDate"))){ |
|
|
|
|
date=c.getMethod("getDate").invoke(readRowHolder.getCurrentRowAnalysisResult()).toString().replace("\uE001","").replace("\uE002",""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < methods.length; i++) { |
|
|
|
|
if (date.equals("")){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (methods[i].equals(c.getMethod("setDate",String.class))){ |
|
|
|
|
c.getMethod("setDate",String.class).invoke(readRowHolder.getCurrentRowAnalysisResult(),date); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
readListener.invokeHead(cellDataMap, analysisContext); |
|
|
|
|
} |
|
|
|
@ -147,4 +168,6 @@ public class DefaultAnalysisEventProcessor implements AnalysisEventProcessor {
|
|
|
|
|
} |
|
|
|
|
excelHeadPropertyData.setHeadMap(tmpHeadMap); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|