StatusConverter.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.chuanghai.h3c_reporting.conver;
  2. import com.alibaba.excel.converters.Converter;
  3. import com.alibaba.excel.enums.CellDataTypeEnum;
  4. import com.alibaba.excel.metadata.CellData;
  5. import com.alibaba.excel.metadata.GlobalConfiguration;
  6. import com.alibaba.excel.metadata.property.ExcelContentProperty;
  7. /**
  8. * @Author 浮生
  9. * @Date 2023/3/22 14:38
  10. * @PackageName:com.chuanghai.h3c_reporting.conver
  11. * @ClassName: StatusConverter
  12. * @Description: TODO 转换项目状态
  13. * @Version 1.0
  14. */
  15. public class StatusConverter implements Converter<Integer> {
  16. @Override
  17. public Class supportJavaTypeKey() {
  18. return Integer.class;
  19. }
  20. @Override
  21. public CellDataTypeEnum supportExcelTypeKey() {
  22. return CellDataTypeEnum.STRING;
  23. }
  24. @Override
  25. public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
  26. //下面这句似乎有问题
  27. return cellData.getStringValue().equals("已提交") ? 2 : 0;
  28. }
  29. @Override
  30. public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
  31. return new CellData(value == 1 ? "进行中" : (value == 2 ? "已提交" :(value == 3 ? "已失效" : "已关闭")));
  32. }
  33. }