|
|
@ -3,8 +3,11 @@ package com.alibaba.excel.read.processor; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Map.Entry; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.context.AnalysisContext; |
|
|
|
import com.alibaba.excel.context.AnalysisContext; |
|
|
|
|
|
|
|
import com.alibaba.excel.enums.CellDataTypeEnum; |
|
|
|
import com.alibaba.excel.enums.HeadKindEnum; |
|
|
|
import com.alibaba.excel.enums.HeadKindEnum; |
|
|
|
import com.alibaba.excel.enums.RowTypeEnum; |
|
|
|
import com.alibaba.excel.enums.RowTypeEnum; |
|
|
|
import com.alibaba.excel.exception.ExcelAnalysisException; |
|
|
|
import com.alibaba.excel.exception.ExcelAnalysisException; |
|
|
@ -17,6 +20,8 @@ import com.alibaba.excel.read.metadata.property.ExcelReadHeadProperty; |
|
|
|
import com.alibaba.excel.util.ConverterUtils; |
|
|
|
import com.alibaba.excel.util.ConverterUtils; |
|
|
|
import com.alibaba.excel.util.StringUtils; |
|
|
|
import com.alibaba.excel.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
@ -111,6 +116,14 @@ public class DefaultAnalysisEventProcessor implements AnalysisEventProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void buildHead(AnalysisContext analysisContext, Map<Integer, ReadCellData<?>> cellDataMap) { |
|
|
|
private void buildHead(AnalysisContext analysisContext, Map<Integer, ReadCellData<?>> cellDataMap) { |
|
|
|
|
|
|
|
// Rule out empty head, and then take the largest column
|
|
|
|
|
|
|
|
if (MapUtils.isNotEmpty(cellDataMap)) { |
|
|
|
|
|
|
|
cellDataMap.entrySet() |
|
|
|
|
|
|
|
.stream() |
|
|
|
|
|
|
|
.filter(entry -> CellDataTypeEnum.EMPTY != entry.getValue().getType()) |
|
|
|
|
|
|
|
.forEach(entry -> analysisContext.readSheetHolder().setMaxNotEmptyDataHeadSize(entry.getKey())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!HeadKindEnum.CLASS.equals(analysisContext.currentReadHolder().excelReadHeadProperty().getHeadKind())) { |
|
|
|
if (!HeadKindEnum.CLASS.equals(analysisContext.currentReadHolder().excelReadHeadProperty().getHeadKind())) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|