All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xinjump.easyexcel.converter.BaseFieldConverter Maven / Gradle / Ivy

The newest version!
package com.xinjump.easyexcel.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public abstract class BaseFieldConverter implements Converter {

    @Override
    public T convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return this.getJavaData(this.getFieldName(excelContentProperty), cellData.getStringValue());
    }

    @Override
    public CellData convertToExcelData(T value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return new CellData<>(this.getExcelData(this.getFieldName(excelContentProperty), value));
    }

    private String getFieldName(ExcelContentProperty excelContentProperty) {
        return excelContentProperty.getField().getName();
    }

    public abstract T getJavaData(String fieldName, String value);

    public abstract String getExcelData(String fieldName, T value);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy