From 71a341c05b660f70b8956736382e7df0cc88d760 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Mon, 2 Sep 2019 10:13:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=E7=A9=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E7=9A=84=E6=97=B6=E5=80=99=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=BD=AC=E6=8D=A2=E5=BC=82=E5=B8=B8=20#520?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/alibaba/excel/metadata/CellData.java | 3 ++- .../alibaba/easyexcel/test/temp/simple/HgTest.java | 13 ++----------- update.md | 1 + 3 files changed, 5 insertions(+), 12 deletions(-) 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 * 优化读写逻辑