You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
821 B

  1. package com.example.demo.Export;
  2. import com.alibaba.excel.annotation.ExcelProperty;
  3. import com.alibaba.excel.converters.Converter;
  4. import com.alibaba.excel.metadata.GlobalConfiguration;
  5. import com.alibaba.excel.metadata.data.WriteCellData;
  6. import com.alibaba.excel.metadata.property.ExcelContentProperty;
  7. public class RefundConverter implements Converter<Integer> {
  8. @Override
  9. public Class<?> supportJavaTypeKey() {
  10. return Integer.class; // 支持的字段类型
  11. }
  12. @Override
  13. public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
  14. // 将 0 映射为 "否",1 映射为 "是"
  15. String result = (value != null && value == 1) ? "是" : "否";
  16. return new WriteCellData<>(result);
  17. }
  18. }