diff --git a/src/main/java/com/alibaba/excel/metadata/CellData.java b/src/main/java/com/alibaba/excel/metadata/CellData.java index adfb091a..0a1ffeb0 100644 --- a/src/main/java/com/alibaba/excel/metadata/CellData.java +++ b/src/main/java/com/alibaba/excel/metadata/CellData.java @@ -1,6 +1,7 @@ package com.alibaba.excel.metadata; import com.alibaba.excel.enums.CellDataTypeEnum; +import com.alibaba.excel.util.StringUtils; /** * Excel internal cell data @@ -175,7 +176,7 @@ public class CellData { switch (type) { case STRING: case ERROR: - if (stringValue == null) { + if (StringUtils.isEmpty(stringValue)) { type = CellDataTypeEnum.EMPTY; } return; diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgTest.java index f5c33a2f..17e22de6 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgTest.java @@ -1,23 +1,14 @@ package com.alibaba.easyexcel.test.temp.simple; -import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.List; -import org.apache.poi.xssf.streaming.SXSSFRow; -import org.apache.poi.xssf.streaming.SXSSFSheet; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.apache.poi.xssf.usermodel.XSSFRow; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.alibaba.easyexcel.test.temp.poi.PoiTest; -import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; @@ -32,8 +23,8 @@ public class HgTest { @Test public void hh() throws IOException { - List list = - EasyExcel.read(new FileInputStream("D:\\test\\hg2.xlsx")).sheet().headRowNumber(0).doReadSync(); + List list = EasyExcel.read(new FileInputStream("D:\\test\\hg2.xlsx")).autoTrim(Boolean.FALSE).sheet() + .headRowNumber(0).doReadSync(); for (Object data : list) { LOGGER.info("返回数据:{}", JSON.toJSONString(data)); } diff --git a/update.md b/update.md index 02822274..1062aeb0 100644 --- a/update.md +++ b/update.md @@ -2,6 +2,7 @@ * 加速gc回收 [Issue #511](https://github.com/alibaba/easyexcel/issues/511) * 修改空字符串读取可能读取上个字段的数据的bug * 修改换行数据无法读取的bug +* 修复在空字符串的时候 格式转换异常 [Issue #520](https://github.com/alibaba/easyexcel/issues/520) # 2.0.0-beta1 * 优化读写逻辑