Converter作为EasyExcel中针对读取excel或者写入excel的时候,用于格式转换的问题

    只需要实现Converter接口方法即可

    1. public interface Converter<T> {
    2. /**
    3. * Back to object types in Java
    4. *
    5. * @return Support for Java class
    6. */
    7. Class supportJavaTypeKey();
    8. /**
    9. * Back to object enum in excel
    10. *
    11. * @return Support for {@link CellDataTypeEnum}
    12. */
    13. CellDataTypeEnum supportExcelTypeKey();
    14. /**
    15. * Convert excel objects to Java objects
    16. *
    17. * @param cellData
    18. * Excel cell data.NotNull.
    19. * @param contentProperty
    20. * Content property.Nullable.
    21. * @param globalConfiguration
    22. * Global configuration.NotNull.
    23. * @return Data to put into a Java object
    24. * @throws Exception
    25. * Exception.
    26. */
    27. T convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
    28. GlobalConfiguration globalConfiguration) throws Exception;
    29. /**
    30. * Convert Java objects to excel objects
    31. *
    32. * @param value
    33. * Java Data.NotNull.
    34. * @param contentProperty
    35. * Content property.Nullable.
    36. * @param globalConfiguration
    37. * Global configuration.NotNull.
    38. * @return Data to put into a Excel
    39. * @throws Exception
    40. * Exception.
    41. */
    42. CellData convertToExcelData(T value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration)
    43. throws Exception;
    44. }

    其中convertToJavaData用于读取excel的时候自定义转换
    convertToExcelData用于写入excel的时候进行自定义转换