修改代码bug
parent
b78aff5727
commit
14438d3bd4
@ -0,0 +1,47 @@
|
|||||||
|
package com.baiye.common.excel.converters;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.excel.converters.Converter;
|
||||||
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||||
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
|
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||||
|
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||||
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
|
import com.baiye.constant.DefaultNumberConstants;
|
||||||
|
import com.baiye.enums.ChannelTypeEnum;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Enzo
|
||||||
|
* @date : 2023/12/9
|
||||||
|
*/
|
||||||
|
public class ChannelConverter implements Converter<Integer> {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> supportJavaTypeKey() {
|
||||||
|
return Integer.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellDataTypeEnum supportExcelTypeKey() {
|
||||||
|
return CellDataTypeEnum.STRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
|
if (StringUtils.isNotBlank(cellData.getStringValue())) {
|
||||||
|
return Integer.parseInt(cellData.getStringValue());
|
||||||
|
}
|
||||||
|
return DefaultNumberConstants.MINUS_ONE_NUMBER;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
||||||
|
return ObjectUtil.isNotNull(value) ? new WriteCellData<>(ChannelTypeEnum.find(value)) : new WriteCellData<>(CharSequenceUtil.EMPTY);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue