diff --git a/pom.xml b/pom.xml
index bb5182d8d..783f12074 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.alibaba
easyexcel
- 2.2.2
+ 2.2.3
jar
easyexcel
diff --git a/src/main/java/com/alibaba/excel/converters/NullableObjectConverter.java b/src/main/java/com/alibaba/excel/converters/NullableObjectConverter.java
deleted file mode 100644
index 43b1cb2c9..000000000
--- a/src/main/java/com/alibaba/excel/converters/NullableObjectConverter.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.alibaba.excel.converters;
-
-/**
- * When implementing convertToExcelData
method, pay attention to the reference value
may be
- * null
- *
- * @author JiaJu Zhuang
- **/
-public interface NullableObjectConverter extends Converter {
-
-}
diff --git a/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java b/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java
index 12250f197..4eb115c50 100644
--- a/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java
+++ b/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java
@@ -10,7 +10,6 @@
import com.alibaba.excel.context.WriteContext;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ConverterKeyBuild;
-import com.alibaba.excel.converters.NullableObjectConverter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.alibaba.excel.metadata.CellData;
@@ -33,10 +32,11 @@ public AbstractExcelWriteExecutor(WriteContext writeContext) {
protected CellData converterAndSet(WriteHolder currentWriteHolder, Class clazz, Cell cell, Object value,
ExcelContentProperty excelContentProperty, Head head, Integer relativeRowIndex) {
- boolean needTrim =
- value != null && (value instanceof String && currentWriteHolder.globalConfiguration().getAutoTrim());
- if (needTrim) {
- value = ((String) value).trim();
+ if (value == null) {
+ return new CellData(CellDataTypeEnum.EMPTY);
+ }
+ if (value instanceof String && currentWriteHolder.globalConfiguration().getAutoTrim()) {
+ value = ((String)value).trim();
}
CellData cellData = convert(currentWriteHolder, clazz, cell, value, excelContentProperty);
if (cellData.getFormula() != null && cellData.getFormula()) {
@@ -70,6 +70,9 @@ protected CellData converterAndSet(WriteHolder currentWriteHolder, Class clazz,
protected CellData convert(WriteHolder currentWriteHolder, Class clazz, Cell cell, Object value,
ExcelContentProperty excelContentProperty) {
+ if (value == null) {
+ return new CellData(CellDataTypeEnum.EMPTY);
+ }
// This means that the user has defined the data.
if (value instanceof CellData) {
CellData cellDataValue = (CellData)value;
@@ -107,9 +110,6 @@ private CellData doConvert(WriteHolder currentWriteHolder, Class clazz, Cell cel
new CellData(CellDataTypeEnum.EMPTY), excelContentProperty,
"Can not find 'Converter' support class " + clazz.getSimpleName() + ".");
}
- if (value == null && !(converter instanceof NullableObjectConverter)) {
- return new CellData(CellDataTypeEnum.EMPTY);
- }
CellData cellData;
try {
cellData =
diff --git a/src/test/java/com/alibaba/easyexcel/test/core/fill/FillDataTest.java b/src/test/java/com/alibaba/easyexcel/test/core/fill/FillDataTest.java
index 5c400305e..3df12b1c8 100644
--- a/src/test/java/com/alibaba/easyexcel/test/core/fill/FillDataTest.java
+++ b/src/test/java/com/alibaba/easyexcel/test/core/fill/FillDataTest.java
@@ -147,11 +147,11 @@ private void compositeFill(File file, File template) {
excelWriter.finish();
List