Converter作为EasyExcel中针对读取excel或者写入excel的时候,用于格式转换的问题
只需要实现Converter
public interface Converter<T> {
/**
* Back to object types in Java
*
* @return Support for Java class
*/
Class supportJavaTypeKey();
/**
* Back to object enum in excel
*
* @return Support for {@link CellDataTypeEnum}
*/
CellDataTypeEnum supportExcelTypeKey();
/**
* Convert excel objects to Java objects
*
* @param cellData
* Excel cell data.NotNull.
* @param contentProperty
* Content property.Nullable.
* @param globalConfiguration
* Global configuration.NotNull.
* @return Data to put into a Java object
* @throws Exception
* Exception.
*/
T convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws Exception;
/**
* Convert Java objects to excel objects
*
* @param value
* Java Data.NotNull.
* @param contentProperty
* Content property.Nullable.
* @param globalConfiguration
* Global configuration.NotNull.
* @return Data to put into a Excel
* @throws Exception
* Exception.
*/
CellData convertToExcelData(T value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration)
throws Exception;
}
其中convertToJavaData用于读取excel的时候自定义转换
convertToExcelData用于写入excel的时候进行自定义转换