使用EasyExcel报表导入导出时对其中的字段进行转换
@Override
public CellData convertToExcelData(String code, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
if(StringUtils.isBlank(code)){
return new CellData("");
}else {
try {
RedisUtils redisUtils = SpringUtil.getBean(RedisUtils.class);
String s = redisUtils.get("WYM" + code);
log.info("单位:" + s);
return new CellData(s);
}catch (Exception e){
log.error("错误",e);
return new CellData(code);
}
}
}
这里我需要使用RedisUtils,刚开始我是直接使用@Autowired注解来注入的但是一直报空指针,改成上面的方法来注入就可以解决问题了