package org.jeecg.modules.aq.vo;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.data.WriteCellData;
import org.jeecg.modules.aq.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
- String and string converter
- @author Jiaju Zhuang
*/
@component
public class CustomStringStringConverter implements Converter {
@Autowired
private CommonService commonService;
@OverRide
public Class<?> supportJavaTypeKey() {
return String.class;
}
@OverRide
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
/**
- 这里是读的时候会调用 不用管
- @return
*/
@OverRide
public String convertToJavaData(ReadConverterContext<?> context) {
return context.getReadCellData().getStringValue();
}
/**
- 这里是写的时候会调用 不用管
- @return
*/
@OverRide
public WriteCellData<?> convertToExcelData(WriteConverterContext context) {
// Map<String, String> categoryMap = commonService.categoryMap();
if (/categoryMap.containsKey(context.getValue())/true) {
// WriteCellData writeCellData = new WriteCellData<>(categoryMap.get(context.getValue()));
WriteCellData writeCellData = new WriteCellData<>("");
return writeCellData;
}
return new WriteCellData<>("");
}
}
1条答案
按热度按时间k7fdbhmy1#