content: package com.xiliu.server.modules.system.vo;
  
  import com.alibaba.excel.converters.Converter;
  import com.alibaba.excel.enums.CellDataTypeEnum;
  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;
  
  /**
   * @author huoqiang
   * @description 状态字符串处理
   * @date 2022/10/25
   */
  public class StatusConverter implements Converter<Integer> {
  
      @Override
      public Class supportJavaTypeKey() {
          return Integer.class;
      }
  
      @Override
      public CellDataTypeEnum supportExcelTypeKey() {
          return CellDataTypeEnum.STRING;
      }
  
      @Override
      public Integer convertToJavaData(ReadCellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
          return "失败".equals(cellData.getStringValue()) ? 1 : 0;
      }
  
      @Override
      public WriteCellData convertToExcelData(Integer value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
          return new WriteCellData(0 == value ? "成功" : "失败");
      }
  }
  