ByteNumberConverter.java 1.0 KB
Newer Older
Z
zhuangjiaju 已提交
1 2 3 4 5
package com.alibaba.excel.converters.byteconverter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
6
import com.alibaba.excel.metadata.GlobalConfiguration;
Z
zhuangjiaju 已提交
7
import com.alibaba.excel.metadata.property.ExcelContentProperty;
Z
zhuangjiaju 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

/**
 * Byte and number converter
 *
 * @author zhuangjiaju
 */
public class ByteNumberConverter implements Converter<Byte> {

    @Override
    public Class supportJavaTypeKey() {
        return Byte.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.NUMBER;
    }

    @Override
27 28
    public Byte convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
        GlobalConfiguration globalConfiguration) {
Z
zhuangjiaju 已提交
29 30 31 32
        return cellData.getDoubleValue().byteValue();
    }

    @Override
33 34
    public CellData convertToExcelData(Byte value, ExcelContentProperty contentProperty,
        GlobalConfiguration globalConfiguration) {
Z
zhuangjiaju 已提交
35
        return new CellData(value.doubleValue());
Z
zhuangjiaju 已提交
36 37 38
    }

}