| | |
| | | import cn.hutool.core.convert.Convert; |
| | | 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.data.ReadCellData; |
| | | import com.alibaba.excel.metadata.data.WriteCellData; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.core.service.DictService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Object convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { |
| | | public Object convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { |
| | | ExcelDictFormat anno = getAnnotation(contentProperty.getField()); |
| | | String type = anno.dictType(); |
| | | String label = cellData.getStringValue(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public CellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { |
| | | public WriteCellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { |
| | | if (StringUtils.isNull(object)) { |
| | | return new CellData<>(""); |
| | | return new WriteCellData<>(""); |
| | | } |
| | | ExcelDictFormat anno = getAnnotation(contentProperty.getField()); |
| | | String type = anno.dictType(); |
| | |
| | | } else { |
| | | label = SpringUtils.getBean(DictService.class).getDictLabel(type, value, anno.separator()); |
| | | } |
| | | return new CellData<>(label); |
| | | return new WriteCellData<>(label); |
| | | } |
| | | |
| | | private ExcelDictFormat getAnnotation(Field field) { |