package com.ruoyi.converter;
|
|
import com.alibaba.excel.converters.Converter;
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
import com.alibaba.excel.metadata.CellData;
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
|
/**
|
* @Author Jinquan_Ou
|
* @Description
|
* @Date 2023-04-26 15:09
|
* @Version 1.0.0
|
**/
|
@SuppressWarnings("rawtypes")
|
public class BearStatusConverter implements Converter<Integer> {
|
@Override
|
public Class supportJavaTypeKey() {
|
return Integer.class;
|
}
|
|
@Override
|
public CellDataTypeEnum supportExcelTypeKey() {
|
return CellDataTypeEnum.STRING;
|
}
|
|
@Override
|
public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
Integer value = 0;
|
String str = cellData.getStringValue();
|
if ("未婚".equals(str)) {
|
value = 0;
|
} else if ("初婚".equals(str)) {
|
value = 1;
|
} else if ("离婚".equals(str)) {
|
value = 2;
|
} else if ("再婚".equals(str)) {
|
value = 3;
|
}
|
return value;
|
}
|
|
@Override
|
public CellData convertToExcelData(Integer value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
String str="其他";
|
if(0==value){
|
str="未婚";
|
}else if (1==value){
|
str="初婚";
|
} else if (2==value) {
|
str="离婚";
|
}else if (3==value){
|
str="再婚";
|
}
|
return new CellData(str);
|
}
|
}
|