| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package com.chuanghai.h3c_reporting.conver;
- 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 浮生
- * @Date 2023/3/22 14:38
- * @PackageName:com.chuanghai.h3c_reporting.conver
- * @ClassName: StatusConverter
- * @Description: TODO 转换项目状态
- * @Version 1.0
- */
- public class StatusConverter implements Converter<Integer> {
- @Override
- public Class supportJavaTypeKey() {
- return Integer.class;
- }
- @Override
- public CellDataTypeEnum supportExcelTypeKey() {
- return CellDataTypeEnum.STRING;
- }
- @Override
- public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
- //下面这句似乎有问题
- return cellData.getStringValue().equals("已提交") ? 2 : 0;
- }
- @Override
- public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
- return new CellData(value == 1 ? "进行中" : (value == 2 ? "已提交" :(value == 3 ? "已失效" : "已关闭")));
- }
- }
|