|
|
@ -64,9 +64,14 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ExcelWriteHeadProperty excelWriteHeadProperty; |
|
|
|
private ExcelWriteHeadProperty excelWriteHeadProperty; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Write handler for workbook |
|
|
|
* Write handler |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Map<Class<? extends WriteHandler>, List<WriteHandler>> writeHandlerMap; |
|
|
|
private Map<Class<? extends WriteHandler>, List<WriteHandler>> writeHandlerMap; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Own write handler.Created in the sheet in the workbook interceptors will not be executed because the workbook to |
|
|
|
|
|
|
|
* create an event long past. So when initializing sheet, supplementary workbook event. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<Class<? extends WriteHandler>, List<WriteHandler>> ownWriteHandlerMap; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Use the default style.Default is true. |
|
|
|
* Use the default style.Default is true. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -177,21 +182,22 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ |
|
|
|
List<WriteHandler> handlerList = new ArrayList<WriteHandler>(); |
|
|
|
List<WriteHandler> handlerList = new ArrayList<WriteHandler>(); |
|
|
|
|
|
|
|
|
|
|
|
// Initialization Annotation
|
|
|
|
// Initialization Annotation
|
|
|
|
initAnnotationConfig(handlerList); |
|
|
|
initAnnotationConfig(handlerList, writeBasicParameter); |
|
|
|
|
|
|
|
|
|
|
|
if (writeBasicParameter.getCustomWriteHandlerList() != null |
|
|
|
if (writeBasicParameter.getCustomWriteHandlerList() != null |
|
|
|
&& !writeBasicParameter.getCustomWriteHandlerList().isEmpty()) { |
|
|
|
&& !writeBasicParameter.getCustomWriteHandlerList().isEmpty()) { |
|
|
|
handlerList.addAll(writeBasicParameter.getCustomWriteHandlerList()); |
|
|
|
handlerList.addAll(writeBasicParameter.getCustomWriteHandlerList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.ownWriteHandlerMap = sortAndClearUpHandler(handlerList); |
|
|
|
|
|
|
|
|
|
|
|
Map<Class<? extends WriteHandler>, List<WriteHandler>> parentWriteHandlerMap = null; |
|
|
|
Map<Class<? extends WriteHandler>, List<WriteHandler>> parentWriteHandlerMap = null; |
|
|
|
if (parentAbstractWriteHolder != null) { |
|
|
|
if (parentAbstractWriteHolder != null) { |
|
|
|
parentWriteHandlerMap = parentAbstractWriteHolder.getWriteHandlerMap(); |
|
|
|
parentWriteHandlerMap = parentAbstractWriteHolder.getWriteHandlerMap(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
handlerList.addAll(DefaultWriteHandlerLoader.loadDefaultHandler(useDefaultStyle)); |
|
|
|
handlerList.addAll(DefaultWriteHandlerLoader.loadDefaultHandler(useDefaultStyle)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.writeHandlerMap = sortAndClearUpAllHandler(handlerList, parentWriteHandlerMap); |
|
|
|
this.writeHandlerMap = sortAndClearUpHandler(handlerList, parentWriteHandlerMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set converterMap
|
|
|
|
// Set converterMap
|
|
|
|
if (parentAbstractWriteHolder == null) { |
|
|
|
if (parentAbstractWriteHolder == null) { |
|
|
@ -279,10 +285,13 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void initAnnotationConfig(List<WriteHandler> handlerList) { |
|
|
|
protected void initAnnotationConfig(List<WriteHandler> handlerList, WriteBasicParameter writeBasicParameter) { |
|
|
|
if (!HeadKindEnum.CLASS.equals(getExcelWriteHeadProperty().getHeadKind())) { |
|
|
|
if (!HeadKindEnum.CLASS.equals(getExcelWriteHeadProperty().getHeadKind())) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (writeBasicParameter.getClazz() == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
Map<Integer, Head> headMap = getExcelWriteHeadProperty().getHeadMap(); |
|
|
|
Map<Integer, Head> headMap = getExcelWriteHeadProperty().getHeadMap(); |
|
|
|
boolean hasColumnWidth = false; |
|
|
|
boolean hasColumnWidth = false; |
|
|
|
boolean hasStyle = false; |
|
|
|
boolean hasStyle = false; |
|
|
@ -308,7 +317,6 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ |
|
|
|
|
|
|
|
|
|
|
|
dealRowHigh(handlerList); |
|
|
|
dealRowHigh(handlerList); |
|
|
|
dealOnceAbsoluteMerge(handlerList); |
|
|
|
dealOnceAbsoluteMerge(handlerList); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void dealStyle(List<WriteHandler> handlerList) { |
|
|
|
private void dealStyle(List<WriteHandler> handlerList) { |
|
|
@ -376,9 +384,9 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ |
|
|
|
handlerList.add(columnWidthStyleStrategy); |
|
|
|
handlerList.add(columnWidthStyleStrategy); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected Map<Class<? extends WriteHandler>, List<WriteHandler>> sortAndClearUpHandler( |
|
|
|
|
|
|
|
List<WriteHandler> handlerList, Map<Class<? extends WriteHandler>, List<WriteHandler>> parentHandlerMap) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Map<Class<? extends WriteHandler>, List<WriteHandler>> sortAndClearUpAllHandler( |
|
|
|
|
|
|
|
List<WriteHandler> handlerList, Map<Class<? extends WriteHandler>, List<WriteHandler>> parentHandlerMap) { |
|
|
|
// add
|
|
|
|
// add
|
|
|
|
if (parentHandlerMap != null) { |
|
|
|
if (parentHandlerMap != null) { |
|
|
|
List<WriteHandler> parentWriteHandler = parentHandlerMap.get(WriteHandler.class); |
|
|
|
List<WriteHandler> parentWriteHandler = parentHandlerMap.get(WriteHandler.class); |
|
|
@ -386,7 +394,11 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ |
|
|
|
handlerList.addAll(parentWriteHandler); |
|
|
|
handlerList.addAll(parentWriteHandler); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return sortAndClearUpHandler(handlerList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Map<Class<? extends WriteHandler>, List<WriteHandler>> sortAndClearUpHandler( |
|
|
|
|
|
|
|
List<WriteHandler> handlerList) { |
|
|
|
// sort
|
|
|
|
// sort
|
|
|
|
Map<Integer, List<WriteHandler>> orderExcelWriteHandlerMap = new TreeMap<Integer, List<WriteHandler>>(); |
|
|
|
Map<Integer, List<WriteHandler>> orderExcelWriteHandlerMap = new TreeMap<Integer, List<WriteHandler>>(); |
|
|
|
for (WriteHandler handler : handlerList) { |
|
|
|
for (WriteHandler handler : handlerList) { |
|
|
@ -480,6 +492,15 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ |
|
|
|
this.writeHandlerMap = writeHandlerMap; |
|
|
|
this.writeHandlerMap = writeHandlerMap; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<Class<? extends WriteHandler>, List<WriteHandler>> getOwnWriteHandlerMap() { |
|
|
|
|
|
|
|
return ownWriteHandlerMap; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setOwnWriteHandlerMap( |
|
|
|
|
|
|
|
Map<Class<? extends WriteHandler>, List<WriteHandler>> ownWriteHandlerMap) { |
|
|
|
|
|
|
|
this.ownWriteHandlerMap = ownWriteHandlerMap; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ExcelWriteHeadProperty getExcelWriteHeadProperty() { |
|
|
|
public ExcelWriteHeadProperty getExcelWriteHeadProperty() { |
|
|
|
return excelWriteHeadProperty; |
|
|
|
return excelWriteHeadProperty; |
|
|
|
} |
|
|
|
} |
|
|
@ -554,6 +575,11 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ |
|
|
|
return getWriteHandlerMap(); |
|
|
|
return getWriteHandlerMap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Map<Class<? extends WriteHandler>, List<WriteHandler>> ownWriteHandlerMap() { |
|
|
|
|
|
|
|
return getOwnWriteHandlerMap(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean needHead() { |
|
|
|
public boolean needHead() { |
|
|
|
return getNeedHead(); |
|
|
|
return getNeedHead(); |
|
|
|