Browse Source

移除弃用代码

pull/2077/head
Jiaju Zhuang 3 years ago
parent
commit
153d4c6e20
  1. 2
      src/main/java/com/alibaba/excel/context/WriteContextImpl.java
  2. 29
      src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java
  3. 55
      src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java
  4. 140
      src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java
  5. 5
      src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java
  6. 2
      src/main/java/com/alibaba/excel/read/metadata/holder/ReadSheetHolder.java
  7. 22
      src/main/java/com/alibaba/excel/read/metadata/holder/ReadWorkbookHolder.java
  8. 4
      src/main/java/com/alibaba/excel/read/metadata/property/ExcelReadHeadProperty.java
  9. 27
      src/main/java/com/alibaba/excel/util/ClassUtils.java
  10. 15
      src/main/java/com/alibaba/excel/write/builder/ExcelWriterBuilder.java
  11. 3
      src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java
  12. 11
      src/main/java/com/alibaba/excel/write/metadata/WriteWorkbook.java
  13. 6
      src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java
  14. 2
      src/main/java/com/alibaba/excel/write/metadata/holder/WriteSheetHolder.java
  15. 32
      src/main/java/com/alibaba/excel/write/metadata/holder/WriteTableHolder.java
  16. 2
      src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java
  17. 24
      src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java

2
src/main/java/com/alibaba/excel/context/WriteContextImpl.java

@ -291,7 +291,7 @@ public class WriteContextImpl implements WriteContext {
}
private void initCurrentTableHolder(WriteTable writeTable) {
writeTableHolder = new WriteTableHolder(writeTable, writeSheetHolder, writeWorkbookHolder);
writeTableHolder = new WriteTableHolder(writeTable, writeSheetHolder);
writeSheetHolder.getHasBeenInitializedTable().put(writeTable.getTableNo(), writeTableHolder);
currentWriteHolder = writeTableHolder;
if (LOGGER.isDebugEnabled()) {

29
src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java

@ -3,7 +3,6 @@ package com.alibaba.excel.metadata.property;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@ -18,6 +17,7 @@ import com.alibaba.excel.exception.ExcelCommonException;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.Holder;
import com.alibaba.excel.util.ClassUtils;
import com.alibaba.excel.util.MapUtils;
import com.alibaba.excel.util.StringUtils;
import com.alibaba.excel.write.metadata.holder.AbstractWriteHolder;
@ -64,19 +64,19 @@ public class ExcelHeadProperty {
*/
private Map<String, Field> ignoreMap;
public ExcelHeadProperty(Holder holder, Class headClazz, List<List<String>> head, Boolean convertAllFiled) {
public ExcelHeadProperty(Holder holder, Class headClazz, List<List<String>> head) {
this.headClazz = headClazz;
headMap = new TreeMap<Integer, Head>();
contentPropertyMap = new TreeMap<Integer, ExcelContentProperty>();
fieldNameContentPropertyMap = new HashMap<String, ExcelContentProperty>();
ignoreMap = new HashMap<String, Field>(16);
headMap = new TreeMap<>();
contentPropertyMap = new TreeMap<>();
fieldNameContentPropertyMap = MapUtils.newHashMap();
ignoreMap = MapUtils.newHashMap();
headKind = HeadKindEnum.NONE;
headRowNumber = 0;
if (head != null && !head.isEmpty()) {
int headIndex = 0;
for (int i = 0; i < head.size(); i++) {
if (holder instanceof AbstractWriteHolder) {
if (((AbstractWriteHolder) holder).ignore(null, i)) {
if (((AbstractWriteHolder)holder).ignore(null, i)) {
continue;
}
}
@ -87,7 +87,7 @@ public class ExcelHeadProperty {
headKind = HeadKindEnum.STRING;
}
// convert headClazz to head
initColumnProperties(holder, convertAllFiled);
initColumnProperties(holder);
initHeadRowNumber();
if (LOGGER.isDebugEnabled()) {
@ -115,7 +115,7 @@ public class ExcelHeadProperty {
}
}
private void initColumnProperties(Holder holder, Boolean convertAllFiled) {
private void initColumnProperties(Holder holder) {
if (headClazz == null) {
return;
}
@ -124,12 +124,11 @@ public class ExcelHeadProperty {
Map<Integer, Field> indexFiledMap = new TreeMap<Integer, Field>();
boolean needIgnore = (holder instanceof AbstractWriteHolder) && (
!CollectionUtils.isEmpty(((AbstractWriteHolder) holder).getExcludeColumnFieldNames()) || !CollectionUtils
.isEmpty(((AbstractWriteHolder) holder).getExcludeColumnIndexes()) || !CollectionUtils
.isEmpty(((AbstractWriteHolder) holder).getIncludeColumnFieldNames()) || !CollectionUtils
.isEmpty(((AbstractWriteHolder) holder).getIncludeColumnIndexes()));
ClassUtils.declaredFields(headClazz, sortedAllFiledMap, indexFiledMap, ignoreMap, convertAllFiled, needIgnore,
holder);
!CollectionUtils.isEmpty(((AbstractWriteHolder)holder).getExcludeColumnFieldNames()) || !CollectionUtils
.isEmpty(((AbstractWriteHolder)holder).getExcludeColumnIndexes()) || !CollectionUtils
.isEmpty(((AbstractWriteHolder)holder).getIncludeColumnFieldNames()) || !CollectionUtils
.isEmpty(((AbstractWriteHolder)holder).getIncludeColumnIndexes()));
ClassUtils.declaredFields(headClazz, sortedAllFiledMap, indexFiledMap, ignoreMap, needIgnore, holder);
for (Map.Entry<Integer, Field> entry : sortedAllFiledMap.entrySet()) {
initOneColumnProperty(entry.getKey(), entry.getValue(), indexFiledMap.containsKey(entry.getKey()));

55
src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java

@ -1,7 +1,5 @@
package com.alibaba.excel.read.listener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.alibaba.excel.context.AnalysisContext;
@ -42,48 +40,25 @@ public class ModelBuildEventListener implements ReadListener<Map<Integer, ReadCe
private Object buildStringList(Map<Integer, ReadCellData<?>> cellDataMap, ReadSheetHolder readSheetHolder,
AnalysisContext context) {
int index = 0;
if (context.readWorkbookHolder().getDefaultReturnMap()) {
Map<Integer, String> map = MapUtils.newLinkedHashMapWithExpectedSize(cellDataMap.size());
for (Map.Entry<Integer, ReadCellData<?>> entry : cellDataMap.entrySet()) {
Integer key = entry.getKey();
ReadCellData<?> cellData = entry.getValue();
while (index < key) {
map.put(index, null);
index++;
}
index++;
map.put(key,
(String)ConverterUtils.convertToJavaObject(cellData, null, null, readSheetHolder.converterMap(),
context, context.readRowHolder().getRowIndex(), key));
}
int headSize = readSheetHolder.excelReadHeadProperty().getHeadMap().size();
while (index < headSize) {
Map<Integer, String> map = MapUtils.newLinkedHashMapWithExpectedSize(cellDataMap.size());
for (Map.Entry<Integer, ReadCellData<?>> entry : cellDataMap.entrySet()) {
Integer key = entry.getKey();
ReadCellData<?> cellData = entry.getValue();
while (index < key) {
map.put(index, null);
index++;
}
return map;
} else {
// Compatible with the old code the old code returns a list
List<String> list = new ArrayList<>();
for (Map.Entry<Integer, ReadCellData<?>> entry : cellDataMap.entrySet()) {
Integer key = entry.getKey();
ReadCellData<?> cellData = entry.getValue();
while (index < key) {
list.add(null);
index++;
}
index++;
list.add(
(String)ConverterUtils.convertToJavaObject(cellData, null, null, readSheetHolder.converterMap(),
context, context.readRowHolder().getRowIndex(), key));
}
int headSize = readSheetHolder.excelReadHeadProperty().getHeadMap().size();
while (index < headSize) {
list.add(null);
index++;
}
return list;
index++;
map.put(key,
(String)ConverterUtils.convertToJavaObject(cellData, null, null, readSheetHolder.converterMap(),
context, context.readRowHolder().getRowIndex(), key));
}
int headSize = readSheetHolder.excelReadHeadProperty().getHeadMap().size();
while (index < headSize) {
map.put(index, null);
index++;
}
return map;
}
private Object buildUserModel(Map<Integer, ReadCellData<?>> cellDataMap, ReadSheetHolder readSheetHolder,

140
src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java

@ -14,11 +14,14 @@ import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.read.listener.ModelBuildEventListener;
import com.alibaba.excel.support.ExcelTypeEnum;
import lombok.Data;
/**
* Workbook
*
* @author Jiaju Zhuang
**/
@Data
public class ReadWorkbook extends ReadBasicParameter {
/**
* Excel type
@ -91,141 +94,4 @@ public class ReadWorkbook extends ReadBasicParameter {
* @see CellExtraTypeEnum
*/
private Set<CellExtraTypeEnum> extraReadSet;
/**
* The default is all excel objects.Default is true.
* <p>
* if true , you can use {@link com.alibaba.excel.annotation.ExcelIgnore} ignore a field.
* <p>
* if false , you must use {@link com.alibaba.excel.annotation.ExcelProperty} to use a filed.
*
* @deprecated Just to be compatible with historical data, The default is always going to be convert all filed.
*/
@Deprecated
private Boolean convertAllFiled;
/**
* List is returned by default, now map is returned by default
*/
@Deprecated
private Boolean defaultReturnMap;
public ExcelTypeEnum getExcelType() {
return excelType;
}
public void setExcelType(ExcelTypeEnum excelType) {
this.excelType = excelType;
}
public InputStream getInputStream() {
return inputStream;
}
public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public Boolean getAutoCloseStream() {
return autoCloseStream;
}
public void setAutoCloseStream(Boolean autoCloseStream) {
this.autoCloseStream = autoCloseStream;
}
public Object getCustomObject() {
return customObject;
}
public void setCustomObject(Object customObject) {
this.customObject = customObject;
}
public Boolean getMandatoryUseInputStream() {
return mandatoryUseInputStream;
}
public void setMandatoryUseInputStream(Boolean mandatoryUseInputStream) {
this.mandatoryUseInputStream = mandatoryUseInputStream;
}
public ReadCache getReadCache() {
return readCache;
}
public void setReadCache(ReadCache readCache) {
this.readCache = readCache;
}
public Boolean getConvertAllFiled() {
return convertAllFiled;
}
public void setConvertAllFiled(Boolean convertAllFiled) {
this.convertAllFiled = convertAllFiled;
}
public Boolean getDefaultReturnMap() {
return defaultReturnMap;
}
public void setDefaultReturnMap(Boolean defaultReturnMap) {
this.defaultReturnMap = defaultReturnMap;
}
public Boolean getIgnoreEmptyRow() {
return ignoreEmptyRow;
}
public void setIgnoreEmptyRow(Boolean ignoreEmptyRow) {
this.ignoreEmptyRow = ignoreEmptyRow;
}
public ReadCacheSelector getReadCacheSelector() {
return readCacheSelector;
}
public void setReadCacheSelector(ReadCacheSelector readCacheSelector) {
this.readCacheSelector = readCacheSelector;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getXlsxSAXParserFactoryName() {
return xlsxSAXParserFactoryName;
}
public void setXlsxSAXParserFactoryName(String xlsxSAXParserFactoryName) {
this.xlsxSAXParserFactoryName = xlsxSAXParserFactoryName;
}
public Boolean getUseDefaultListener() {
return useDefaultListener;
}
public void setUseDefaultListener(Boolean useDefaultListener) {
this.useDefaultListener = useDefaultListener;
}
public Set<CellExtraTypeEnum> getExtraReadSet() {
return extraReadSet;
}
public void setExtraReadSet(Set<CellExtraTypeEnum> extraReadSet) {
this.extraReadSet = extraReadSet;
}
}

5
src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java

@ -46,8 +46,7 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
*/
private List<ReadListener<?>> readListenerList;
public AbstractReadHolder(ReadBasicParameter readBasicParameter, AbstractReadHolder parentAbstractReadHolder,
Boolean convertAllFiled) {
public AbstractReadHolder(ReadBasicParameter readBasicParameter, AbstractReadHolder parentAbstractReadHolder) {
super(readBasicParameter, parentAbstractReadHolder);
if (readBasicParameter.getUseScientificFormat() == null) {
@ -60,7 +59,7 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
}
// Initialization property
this.excelReadHeadProperty = new ExcelReadHeadProperty(this, getClazz(), getHead(), convertAllFiled);
this.excelReadHeadProperty = new ExcelReadHeadProperty(this, getClazz(), getHead());
if (readBasicParameter.getHeadRowNumber() == null) {
if (parentAbstractReadHolder == null) {
if (excelReadHeadProperty.hasHead()) {

2
src/main/java/com/alibaba/excel/read/metadata/holder/ReadSheetHolder.java

@ -59,7 +59,7 @@ public class ReadSheetHolder extends AbstractReadHolder {
private ReadCellData<?> tempCellData;
public ReadSheetHolder(ReadSheet readSheet, ReadWorkbookHolder readWorkbookHolder) {
super(readSheet, readWorkbookHolder, readWorkbookHolder.getReadWorkbook().getConvertAllFiled());
super(readSheet, readWorkbookHolder);
this.readSheet = readSheet;
this.parentReadWorkbookHolder = readWorkbookHolder;
this.sheetNo = readSheet.getSheetNo();

22
src/main/java/com/alibaba/excel/read/metadata/holder/ReadWorkbookHolder.java

@ -106,28 +106,13 @@ public class ReadWorkbookHolder extends AbstractReadHolder {
*/
private Boolean readAll;
/**
* The default is all excel objects.if true , you can use {@link com.alibaba.excel.annotation.ExcelIgnore} ignore a
* field. if false , you must use {@link com.alibaba.excel.annotation.ExcelProperty} to use a filed.
*
* @deprecated Just to be compatible with historical data, The default is always going to be convert all filed.
*/
@Deprecated
private Boolean convertAllFiled;
/**
* List is returned by default, now map is returned by default
*/
@Deprecated
private Boolean defaultReturnMap;
/**
* Prevent repeating sheet
*/
private Set<Integer> hasReadSheet;
public ReadWorkbookHolder(ReadWorkbook readWorkbook) {
super(readWorkbook, null, readWorkbook.getConvertAllFiled());
super(readWorkbook, null);
this.readWorkbook = readWorkbook;
if (readWorkbook.getInputStream() != null) {
this.inputStream = readWorkbook.getInputStream();
@ -162,11 +147,6 @@ public class ReadWorkbookHolder extends AbstractReadHolder {
this.readCacheSelector = readWorkbook.getReadCacheSelector();
}
}
if (readWorkbook.getDefaultReturnMap() == null) {
this.defaultReturnMap = Boolean.TRUE;
} else {
this.defaultReturnMap = readWorkbook.getDefaultReturnMap();
}
if (readWorkbook.getExtraReadSet() == null) {
this.extraReadSet = new HashSet<CellExtraTypeEnum>();
} else {

4
src/main/java/com/alibaba/excel/read/metadata/property/ExcelReadHeadProperty.java

@ -12,7 +12,7 @@ import com.alibaba.excel.metadata.property.ExcelHeadProperty;
*/
public class ExcelReadHeadProperty extends ExcelHeadProperty {
public ExcelReadHeadProperty(Holder holder, Class headClazz, List<List<String>> head, Boolean convertAllFiled) {
super(holder, headClazz, head, convertAllFiled);
public ExcelReadHeadProperty(Holder holder, Class headClazz, List<List<String>> head) {
super(holder, headClazz, head);
}
}

27
src/main/java/com/alibaba/excel/util/ClassUtils.java

@ -30,9 +30,8 @@ public class ClassUtils {
public static final Map<Class<?>, SoftReference<FieldCache>> FIELD_CACHE = new ConcurrentHashMap<>();
public static void declaredFields(Class<?> clazz, Map<Integer, Field> sortedAllFiledMap,
Map<Integer, Field> indexFiledMap, Map<String, Field> ignoreMap, Boolean convertAllFiled,
Boolean needIgnore, Holder holder) {
FieldCache fieldCache = getFieldCache(clazz, convertAllFiled);
Map<Integer, Field> indexFiledMap, Map<String, Field> ignoreMap, Boolean needIgnore, Holder holder) {
FieldCache fieldCache = getFieldCache(clazz);
if (fieldCache == null) {
return;
}
@ -68,12 +67,12 @@ public class ClassUtils {
}
}
public static void declaredFields(Class<?> clazz, Map<Integer, Field> sortedAllFiledMap, Boolean convertAllFiled,
Boolean needIgnore, WriteHolder writeHolder) {
declaredFields(clazz, sortedAllFiledMap, null, null, convertAllFiled, needIgnore, writeHolder);
public static void declaredFields(Class<?> clazz, Map<Integer, Field> sortedAllFiledMap, Boolean needIgnore,
WriteHolder writeHolder) {
declaredFields(clazz, sortedAllFiledMap, null, null, needIgnore, writeHolder);
}
private static FieldCache getFieldCache(Class<?> clazz, Boolean convertAllFiled) {
private static FieldCache getFieldCache(Class<?> clazz) {
if (clazz == null) {
return null;
}
@ -86,12 +85,12 @@ public class ClassUtils {
if (fieldCacheSoftReference != null && fieldCacheSoftReference.get() != null) {
return fieldCacheSoftReference.get();
}
declaredFields(clazz, convertAllFiled);
declaredFields(clazz);
}
return FIELD_CACHE.get(clazz).get();
}
private static void declaredFields(Class<?> clazz, Boolean convertAllFiled) {
private static void declaredFields(Class<?> clazz) {
List<Field> tempFieldList = new ArrayList<>();
Class<?> tempClass = clazz;
// When the parent class is null, it indicates that the parent class (Object class) has reached the top
@ -108,7 +107,7 @@ public class ClassUtils {
ExcelIgnoreUnannotated excelIgnoreUnannotated = clazz.getAnnotation(ExcelIgnoreUnannotated.class);
for (Field field : tempFieldList) {
declaredOneField(field, orderFiledMap, indexFiledMap, ignoreMap, excelIgnoreUnannotated, convertAllFiled);
declaredOneField(field, orderFiledMap, indexFiledMap, ignoreMap, excelIgnoreUnannotated);
}
FIELD_CACHE.put(clazz, new SoftReference<FieldCache>(
new FieldCache(buildSortedAllFiledMap(orderFiledMap, indexFiledMap), indexFiledMap, ignoreMap)));
@ -138,16 +137,16 @@ public class ClassUtils {
}
private static void declaredOneField(Field field, Map<Integer, List<Field>> orderFiledMap,
Map<Integer, Field> indexFiledMap, Map<String, Field> ignoreMap, ExcelIgnoreUnannotated excelIgnoreUnannotated,
Boolean convertAllFiled) {
Map<Integer, Field> indexFiledMap, Map<String, Field> ignoreMap,
ExcelIgnoreUnannotated excelIgnoreUnannotated) {
ExcelIgnore excelIgnore = field.getAnnotation(ExcelIgnore.class);
if (excelIgnore != null) {
ignoreMap.put(field.getName(), field);
return;
}
ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);
boolean noExcelProperty = excelProperty == null
&& ((convertAllFiled != null && !convertAllFiled) || excelIgnoreUnannotated != null);
boolean noExcelProperty = excelProperty == null && excelIgnoreUnannotated != null;
if (noExcelProperty) {
ignoreMap.put(field.getName(), field);
return;

15
src/main/java/com/alibaba/excel/write/builder/ExcelWriterBuilder.java

@ -65,21 +65,6 @@ public class ExcelWriterBuilder extends AbstractExcelWriterParameterBuilder<Exce
return this;
}
/**
* The default is all excel objects.if true , you can use {@link com.alibaba.excel.annotation.ExcelIgnore} ignore a
* field. if false , you must use {@link com.alibaba.excel.annotation.ExcelProperty} to use a filed.
* <p>
* Default true
*
* @param convertAllFiled
* @return
* @deprecated Just to be compatible with historical data, The default is always going to be convert all filed.
*/
@Deprecated
public ExcelWriterBuilder convertAllFiled(Boolean convertAllFiled) {
writeWorkbook.setConvertAllFiled(convertAllFiled);
return this;
}
public ExcelWriterBuilder excelType(ExcelTypeEnum excelType) {
writeWorkbook.setExcelType(excelType);

3
src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java

@ -183,8 +183,7 @@ public class ExcelWriteAddExecutor extends AbstractExcelWriteExecutor {
.isEmpty(writeWorkbookHolder.getExcludeColumnIndexes()) || !CollectionUtils
.isEmpty(writeWorkbookHolder.getIncludeColumnFieldNames()) || !CollectionUtils
.isEmpty(writeWorkbookHolder.getIncludeColumnIndexes());
ClassUtils.declaredFields(clazz, sortedAllFiledMap,
writeWorkbookHolder.getWriteWorkbook().getConvertAllFiled(), needIgnore, writeWorkbookHolder);
ClassUtils.declaredFields(clazz, sortedAllFiledMap, needIgnore, writeWorkbookHolder);
}
}

11
src/main/java/com/alibaba/excel/write/metadata/WriteWorkbook.java

@ -74,15 +74,4 @@ public class WriteWorkbook extends WriteBasicParameter {
* Excel is also written in the event of an exception being thrown.The default false.
*/
private Boolean writeExcelOnException;
/**
* The default is all excel objects.Default is true.
* <p>
* if true , you can use {@link com.alibaba.excel.annotation.ExcelIgnore} ignore a field.
* <p>
* if false , you must use {@link com.alibaba.excel.annotation.ExcelProperty} to use a filed.
*
* @deprecated Just to be compatible with historical data, The default is always going to be convert all filed.
*/
@Deprecated
private Boolean convertAllFiled;
}

6
src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java

@ -93,11 +93,9 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
*/
private Collection<String> includeColumnFieldNames;
public AbstractWriteHolder(WriteBasicParameter writeBasicParameter, AbstractWriteHolder parentAbstractWriteHolder,
Boolean convertAllField) {
public AbstractWriteHolder(WriteBasicParameter writeBasicParameter, AbstractWriteHolder parentAbstractWriteHolder) {
super(writeBasicParameter, parentAbstractWriteHolder);
if (writeBasicParameter.getUseScientificFormat() != null) {
throw new UnsupportedOperationException("Currently does not support setting useScientificFormat.");
}
@ -164,7 +162,7 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
}
// Initialization property
this.excelWriteHeadProperty = new ExcelWriteHeadProperty(this, getClazz(), getHead(), convertAllField);
this.excelWriteHeadProperty = new ExcelWriteHeadProperty(this, getClazz(), getHead());
// Set writeHandlerMap
List<WriteHandler> handlerList = new ArrayList<WriteHandler>();

2
src/main/java/com/alibaba/excel/write/metadata/holder/WriteSheetHolder.java

@ -77,7 +77,7 @@ public class WriteSheetHolder extends AbstractWriteHolder {
private Integer lastRowIndex;
public WriteSheetHolder(WriteSheet writeSheet, WriteWorkbookHolder writeWorkbookHolder) {
super(writeSheet, writeWorkbookHolder, writeWorkbookHolder.getWriteWorkbook().getConvertAllFiled());
super(writeSheet, writeWorkbookHolder);
this.writeSheet = writeSheet;
if (writeSheet.getSheetNo() == null && StringUtils.isEmpty(writeSheet.getSheetName())) {
this.sheetNo = 0;

32
src/main/java/com/alibaba/excel/write/metadata/holder/WriteTableHolder.java

@ -3,11 +3,14 @@ package com.alibaba.excel.write.metadata.holder;
import com.alibaba.excel.enums.HolderEnum;
import com.alibaba.excel.write.metadata.WriteTable;
import lombok.Data;
/**
* sheet holder
*
* @author Jiaju Zhuang
*/
@Data
public class WriteTableHolder extends AbstractWriteHolder {
/***
* poi sheet
@ -22,38 +25,13 @@ public class WriteTableHolder extends AbstractWriteHolder {
*/
private WriteTable writeTable;
public WriteTableHolder(WriteTable writeTable, WriteSheetHolder writeSheetHolder,
WriteWorkbookHolder writeWorkbookHolder) {
super(writeTable, writeSheetHolder, writeWorkbookHolder.getWriteWorkbook().getConvertAllFiled());
public WriteTableHolder(WriteTable writeTable, WriteSheetHolder writeSheetHolder) {
super(writeTable, writeSheetHolder);
this.parentWriteSheetHolder = writeSheetHolder;
this.tableNo = writeTable.getTableNo();
this.writeTable = writeTable;
}
public WriteSheetHolder getParentWriteSheetHolder() {
return parentWriteSheetHolder;
}
public void setParentWriteSheetHolder(WriteSheetHolder parentWriteSheetHolder) {
this.parentWriteSheetHolder = parentWriteSheetHolder;
}
public Integer getTableNo() {
return tableNo;
}
public void setTableNo(Integer tableNo) {
this.tableNo = tableNo;
}
public WriteTable getWriteTable() {
return writeTable;
}
public void setWriteTable(WriteTable writeTable) {
this.writeTable = writeTable;
}
@Override
public HolderEnum holderType() {
return HolderEnum.TABLE;

2
src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java

@ -140,7 +140,7 @@ public class WriteWorkbookHolder extends AbstractWriteHolder {
private Map<DataFormatData, Short> dataFormatMap;
public WriteWorkbookHolder(WriteWorkbook writeWorkbook) {
super(writeWorkbook, null, writeWorkbook.getConvertAllFiled());
super(writeWorkbook, null);
this.writeWorkbook = writeWorkbook;
this.file = writeWorkbook.getFile();
if (file != null) {

24
src/main/java/com/alibaba/excel/write/property/ExcelWriteHeadProperty.java

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentFontStyle;
import com.alibaba.excel.annotation.write.style.ContentLoopMerge;
@ -17,9 +16,6 @@ import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import com.alibaba.excel.annotation.write.style.OnceAbsoluteMerge;
import com.alibaba.excel.converters.ConverterKeyBuild;
import com.alibaba.excel.converters.DefaultConverterLoader;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.enums.HeadKindEnum;
import com.alibaba.excel.metadata.CellRange;
import com.alibaba.excel.metadata.Head;
@ -44,23 +40,23 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty {
private RowHeightProperty contentRowHeightProperty;
private OnceAbsoluteMergeProperty onceAbsoluteMergeProperty;
public ExcelWriteHeadProperty(Holder holder, Class headClazz, List<List<String>> head, Boolean convertAllFiled) {
super(holder, headClazz, head, convertAllFiled);
public ExcelWriteHeadProperty(Holder holder, Class headClazz, List<List<String>> head) {
super(holder, headClazz, head);
if (getHeadKind() != HeadKindEnum.CLASS) {
return;
}
this.headRowHeightProperty =
RowHeightProperty.build((HeadRowHeight) headClazz.getAnnotation(HeadRowHeight.class));
RowHeightProperty.build((HeadRowHeight)headClazz.getAnnotation(HeadRowHeight.class));
this.contentRowHeightProperty =
RowHeightProperty.build((ContentRowHeight) headClazz.getAnnotation(ContentRowHeight.class));
RowHeightProperty.build((ContentRowHeight)headClazz.getAnnotation(ContentRowHeight.class));
this.onceAbsoluteMergeProperty =
OnceAbsoluteMergeProperty.build((OnceAbsoluteMerge) headClazz.getAnnotation(OnceAbsoluteMerge.class));
OnceAbsoluteMergeProperty.build((OnceAbsoluteMerge)headClazz.getAnnotation(OnceAbsoluteMerge.class));
ColumnWidth parentColumnWidth = (ColumnWidth) headClazz.getAnnotation(ColumnWidth.class);
HeadStyle parentHeadStyle = (HeadStyle) headClazz.getAnnotation(HeadStyle.class);
HeadFontStyle parentHeadFontStyle = (HeadFontStyle) headClazz.getAnnotation(HeadFontStyle.class);
ContentStyle parentContentStyle = (ContentStyle) headClazz.getAnnotation(ContentStyle.class);
ContentFontStyle parentContentFontStyle = (ContentFontStyle) headClazz.getAnnotation(ContentFontStyle.class);
ColumnWidth parentColumnWidth = (ColumnWidth)headClazz.getAnnotation(ColumnWidth.class);
HeadStyle parentHeadStyle = (HeadStyle)headClazz.getAnnotation(HeadStyle.class);
HeadFontStyle parentHeadFontStyle = (HeadFontStyle)headClazz.getAnnotation(HeadFontStyle.class);
ContentStyle parentContentStyle = (ContentStyle)headClazz.getAnnotation(ContentStyle.class);
ContentFontStyle parentContentFontStyle = (ContentFontStyle)headClazz.getAnnotation(ContentFontStyle.class);
for (Map.Entry<Integer, ExcelContentProperty> entry : getContentPropertyMap().entrySet()) {
Integer index = entry.getKey();

Loading…
Cancel
Save