|
|
|
@ -64,9 +64,14 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
|
|
|
|
|
*/ |
|
|
|
|
private ExcelWriteHeadProperty excelWriteHeadProperty; |
|
|
|
|
/** |
|
|
|
|
* Write handler for workbook |
|
|
|
|
* Write handler |
|
|
|
|
*/ |
|
|
|
|
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. |
|
|
|
|
*/ |
|
|
|
@ -177,21 +182,22 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
|
|
|
|
|
List<WriteHandler> handlerList = new ArrayList<WriteHandler>(); |
|
|
|
|
|
|
|
|
|
// Initialization Annotation
|
|
|
|
|
initAnnotationConfig(handlerList); |
|
|
|
|
initAnnotationConfig(handlerList, writeBasicParameter); |
|
|
|
|
|
|
|
|
|
if (writeBasicParameter.getCustomWriteHandlerList() != null |
|
|
|
|
&& !writeBasicParameter.getCustomWriteHandlerList().isEmpty()) { |
|
|
|
|
handlerList.addAll(writeBasicParameter.getCustomWriteHandlerList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.ownWriteHandlerMap = sortAndClearUpHandler(handlerList); |
|
|
|
|
|
|
|
|
|
Map<Class<? extends WriteHandler>, List<WriteHandler>> parentWriteHandlerMap = null; |
|
|
|
|
if (parentAbstractWriteHolder != null) { |
|
|
|
|
parentWriteHandlerMap = parentAbstractWriteHolder.getWriteHandlerMap(); |
|
|
|
|
} else { |
|
|
|
|
handlerList.addAll(DefaultWriteHandlerLoader.loadDefaultHandler(useDefaultStyle)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.writeHandlerMap = sortAndClearUpHandler(handlerList, parentWriteHandlerMap); |
|
|
|
|
this.writeHandlerMap = sortAndClearUpAllHandler(handlerList, parentWriteHandlerMap); |
|
|
|
|
|
|
|
|
|
// Set converterMap
|
|
|
|
|
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())) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (writeBasicParameter.getClazz() == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
Map<Integer, Head> headMap = getExcelWriteHeadProperty().getHeadMap(); |
|
|
|
|
boolean hasColumnWidth = false; |
|
|
|
|
boolean hasStyle = false; |
|
|
|
@ -308,7 +317,6 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
|
|
|
|
|
|
|
|
|
|
dealRowHigh(handlerList); |
|
|
|
|
dealOnceAbsoluteMerge(handlerList); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void dealStyle(List<WriteHandler> handlerList) { |
|
|
|
@ -376,9 +384,9 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
|
|
|
|
|
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
|
|
|
|
|
if (parentHandlerMap != null) { |
|
|
|
|
List<WriteHandler> parentWriteHandler = parentHandlerMap.get(WriteHandler.class); |
|
|
|
@ -386,7 +394,11 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
|
|
|
|
|
handlerList.addAll(parentWriteHandler); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return sortAndClearUpHandler(handlerList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected Map<Class<? extends WriteHandler>, List<WriteHandler>> sortAndClearUpHandler( |
|
|
|
|
List<WriteHandler> handlerList) { |
|
|
|
|
// sort
|
|
|
|
|
Map<Integer, List<WriteHandler>> orderExcelWriteHandlerMap = new TreeMap<Integer, List<WriteHandler>>(); |
|
|
|
|
for (WriteHandler handler : handlerList) { |
|
|
|
@ -480,6 +492,15 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
|
|
|
|
|
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() { |
|
|
|
|
return excelWriteHeadProperty; |
|
|
|
|
} |
|
|
|
@ -554,6 +575,11 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
|
|
|
|
|
return getWriteHandlerMap(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<Class<? extends WriteHandler>, List<WriteHandler>> ownWriteHandlerMap() { |
|
|
|
|
return getOwnWriteHandlerMap(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean needHead() { |
|
|
|
|
return getNeedHead(); |
|
|
|
|