forked from fanruan/easyexcel
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.
43 lines
1.1 KiB
43 lines
1.1 KiB
6 years ago
|
package com.alibaba.excel.converters.bigdecimal;
|
||
|
|
||
|
import java.math.BigDecimal;
|
||
|
|
||
|
import com.alibaba.excel.converters.Converter;
|
||
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||
|
import com.alibaba.excel.metadata.CellData;
|
||
|
import com.alibaba.excel.metadata.ExcelColumnProperty;
|
||
|
|
||
|
/**
|
||
|
* BigDecimal and boolean converter
|
||
|
*
|
||
|
* @author zhuangjiaju
|
||
|
*/
|
||
|
public class BigDecimalBooleanConverter implements Converter<BigDecimal> {
|
||
|
|
||
|
@Override
|
||
|
public Class supportJavaTypeKey() {
|
||
|
return BigDecimal.class;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public CellDataTypeEnum supportExcelTypeKey() {
|
||
|
return CellDataTypeEnum.BOOLEAN;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public BigDecimal convertToJavaData(CellData cellData, ExcelColumnProperty columnProperty) {
|
||
|
if (cellData.getBooleanValue()) {
|
||
|
return BigDecimal.ONE;
|
||
|
}
|
||
|
return BigDecimal.ZERO;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public CellData convertToExcelData(BigDecimal value, ExcelColumnProperty columnProperty) {
|
||
|
if (BigDecimal.ONE.equals(value)) {
|
||
|
return new CellData(Boolean.TRUE);
|
||
|
}
|
||
|
return new CellData(Boolean.FALSE);
|
||
|
}
|
||
|
}
|