com.swak.excel.metadata.ExcelWriteData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swak-excel-boot-starter Show documentation
Show all versions of swak-excel-boot-starter Show documentation
swak component of excel spring boot starter
The newest version!
package com.swak.excel.metadata;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.collections4.CollectionUtils;
import java.util.*;
@Data
@Accessors(chain = true)
public class ExcelWriteData implements java.io.Serializable {
private static final long serialVersionUID = 125034374585574874L;
private String sheetName;
private Class> headClazz;
private Collection includeColumnFieldNames;
private Map dynamicTitleHeader;
private Collection data = new ArrayList<>();
private Map> dropSelect = new HashMap<>();
public void addValidSelect(String headerName, List dropSel) {
if (CollectionUtils.isNotEmpty(dropSel)) {
dropSelect.put(headerName, dropSel);
}
}
public String[] getValidSelect(String headerName) {
List list = dropSelect.get(headerName);
return CollectionUtils.isEmpty(list) ? null : list.toArray(new String[list.size()]);
}
public static ExcelWriteData newWriteData(Collection data){
ExcelWriteData excelWriteData = new ExcelWriteData();
excelWriteData.setData(data);
return excelWriteData;
}
public static ExcelWriteData newWriteData(Collection data,Class> headClazz){
ExcelWriteData excelWriteData = newWriteData(data);
excelWriteData.setHeadClazz(headClazz);
return excelWriteData;
}
public static ExcelWriteData newWriteData(Collection data,Class> headClazz,
Collection includeColumnFieldNames){
ExcelWriteData excelWriteData = newWriteData(data,headClazz);
excelWriteData.setIncludeColumnFieldNames(includeColumnFieldNames);
return excelWriteData;
}
public static ExcelWriteData newWriteData(Collection data,Class> headClazz,String sheetName){
ExcelWriteData excelWriteData = newWriteData(data,headClazz);
excelWriteData.setSheetName(sheetName);
return excelWriteData;
}
public static ExcelWriteData newWriteData(Collection data,Class> headClazz,String sheetName,
Collection includeColumnFieldNames){
ExcelWriteData excelWriteData = newWriteData(data,headClazz,sheetName);
excelWriteData.setIncludeColumnFieldNames(includeColumnFieldNames);
return excelWriteData;
}
}