|
|
|
@ -2,11 +2,20 @@ package com.alibaba.excel.write.metadata.fill;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.enums.WriteDirectionEnum; |
|
|
|
|
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.Builder; |
|
|
|
|
import lombok.Data; |
|
|
|
|
import lombok.NoArgsConstructor; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Fill config |
|
|
|
|
* |
|
|
|
|
* @author Jiaju Zhuang |
|
|
|
|
**/ |
|
|
|
|
@Data |
|
|
|
|
@Builder |
|
|
|
|
@NoArgsConstructor |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
public class FillConfig { |
|
|
|
|
private WriteDirectionEnum direction; |
|
|
|
|
/** |
|
|
|
@ -16,23 +25,15 @@ public class FillConfig {
|
|
|
|
|
* say the whole file will be stored in memory. |
|
|
|
|
*/ |
|
|
|
|
private Boolean forceNewRow; |
|
|
|
|
private boolean hasInit; |
|
|
|
|
|
|
|
|
|
public WriteDirectionEnum getDirection() { |
|
|
|
|
return direction; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setDirection(WriteDirectionEnum direction) { |
|
|
|
|
this.direction = direction; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Boolean getForceNewRow() { |
|
|
|
|
return forceNewRow; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Automatically inherit style |
|
|
|
|
* |
|
|
|
|
* default true. |
|
|
|
|
*/ |
|
|
|
|
private Boolean autoStyle; |
|
|
|
|
|
|
|
|
|
public void setForceNewRow(Boolean forceNewRow) { |
|
|
|
|
this.forceNewRow = forceNewRow; |
|
|
|
|
} |
|
|
|
|
private boolean hasInit; |
|
|
|
|
|
|
|
|
|
public void init() { |
|
|
|
|
if (hasInit) { |
|
|
|
@ -44,40 +45,9 @@ public class FillConfig {
|
|
|
|
|
if (forceNewRow == null) { |
|
|
|
|
forceNewRow = Boolean.FALSE; |
|
|
|
|
} |
|
|
|
|
hasInit = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static FillConfigBuilder builder() { |
|
|
|
|
return new FillConfigBuilder(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static class FillConfigBuilder { |
|
|
|
|
private FillConfig fillConfig; |
|
|
|
|
|
|
|
|
|
FillConfigBuilder() { |
|
|
|
|
this.fillConfig = new FillConfig(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FillConfigBuilder direction(WriteDirectionEnum direction) { |
|
|
|
|
fillConfig.setDirection(direction); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FillConfigBuilder forceNewRow(Boolean forceNewRow) { |
|
|
|
|
fillConfig.setForceNewRow(forceNewRow); |
|
|
|
|
return this; |
|
|
|
|
if (autoStyle == null) { |
|
|
|
|
autoStyle = Boolean.TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FillConfig build() { |
|
|
|
|
return build(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FillConfig build(boolean autoInit) { |
|
|
|
|
if (autoInit) { |
|
|
|
|
fillConfig.init(); |
|
|
|
|
} |
|
|
|
|
return fillConfig; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
hasInit = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|