参考:关于Easyexcel | Easy Excel
一、添加类型转换器
public class xxxExcel implements Serializable {@ExcelProperty(value = "xx类型", converter = xxxTypeConverter.class) private Integer eventType;
}
public class xxxTypeConverter implements Converter<Integer> {
@Override
public Class supportJavaTypeKey() {
return Boolean.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
return xxxTypeEnum.translationValue(cellData.getStringValue());
}
@Override
public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
return new CellData(xxxTypeEnum.translationLabel(value));
}
}
二、添加下拉框
给第一列的第2行开始,共5000行添加下拉框。
public class xxxSheetHandler implements SheetWriteHandler {
private final List<xxx> xxxList;
public DeviceSheetHandler(List<xxx> xxxList) {
this.xxxList= xxxList;
}
@Override
pu