Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不停的脚步
easyexcel
提交
fba1f72d
E
easyexcel
项目概览
不停的脚步
/
easyexcel
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
easyexcel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fba1f72d
编写于
4月 27, 2020
作者:
庄家钜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改填充数据空数据的bug #1274
上级
34cd6003
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
25 deletion
+21
-25
pom.xml
pom.xml
+1
-1
src/main/java/com/alibaba/excel/converters/NullableObjectConverter.java
...com/alibaba/excel/converters/NullableObjectConverter.java
+0
-11
src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java
...baba/excel/write/executor/AbstractExcelWriteExecutor.java
+8
-8
src/test/java/com/alibaba/easyexcel/test/core/fill/FillDataTest.java
...va/com/alibaba/easyexcel/test/core/fill/FillDataTest.java
+8
-5
update.md
update.md
+4
-0
未找到文件。
pom.xml
浏览文件 @
fba1f72d
...
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.alibaba
</groupId>
<artifactId>
easyexcel
</artifactId>
<version>
2.2.
2
</version>
<version>
2.2.
3
</version>
<packaging>
jar
</packaging>
<name>
easyexcel
</name>
...
...
src/main/java/com/alibaba/excel/converters/NullableObjectConverter.java
已删除
100644 → 0
浏览文件 @
34cd6003
package
com.alibaba.excel.converters
;
/**
* When implementing <code>convertToExcelData</code> method, pay attention to the reference <code>value</code> may be
* null
*
* @author JiaJu Zhuang
**/
public
interface
NullableObjectConverter
<
T
>
extends
Converter
<
T
>
{
}
src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java
浏览文件 @
fba1f72d
...
...
@@ -10,7 +10,6 @@ import org.apache.poi.ss.usermodel.Sheet;
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 abstract class AbstractExcelWriteExecutor implements ExcelWriteExecutor {
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 @@ public abstract class AbstractExcelWriteExecutor implements ExcelWriteExecutor {
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 @@ public abstract class AbstractExcelWriteExecutor implements ExcelWriteExecutor {
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
=
...
...
src/test/java/com/alibaba/easyexcel/test/core/fill/FillDataTest.java
浏览文件 @
fba1f72d
...
...
@@ -147,11 +147,11 @@ public class FillDataTest {
excelWriter
.
finish
();
List
<
Object
>
list
=
EasyExcel
.
read
(
file
).
ignoreEmptyRow
(
false
).
sheet
().
headRowNumber
(
0
).
doReadSync
();
Map
<
String
,
String
>
map0
=
(
Map
<
String
,
String
>)
list
.
get
(
0
);
Map
<
String
,
String
>
map0
=
(
Map
<
String
,
String
>)
list
.
get
(
0
);
Assert
.
assertEquals
(
"张三"
,
map0
.
get
(
21
));
Map
<
String
,
String
>
map27
=
(
Map
<
String
,
String
>)
list
.
get
(
27
);
Map
<
String
,
String
>
map27
=
(
Map
<
String
,
String
>)
list
.
get
(
27
);
Assert
.
assertEquals
(
"张三"
,
map27
.
get
(
0
));
Map
<
String
,
String
>
map29
=
(
Map
<
String
,
String
>)
list
.
get
(
29
);
Map
<
String
,
String
>
map29
=
(
Map
<
String
,
String
>)
list
.
get
(
29
);
Assert
.
assertEquals
(
"张三"
,
map29
.
get
(
3
));
}
...
...
@@ -168,7 +168,7 @@ public class FillDataTest {
List
<
Object
>
list
=
EasyExcel
.
read
(
file
).
sheet
().
headRowNumber
(
0
).
doReadSync
();
Assert
.
assertEquals
(
list
.
size
(),
5L
);
Map
<
String
,
String
>
map0
=
(
Map
<
String
,
String
>)
list
.
get
(
0
);
Map
<
String
,
String
>
map0
=
(
Map
<
String
,
String
>)
list
.
get
(
0
);
Assert
.
assertEquals
(
"张三"
,
map0
.
get
(
2
));
}
...
...
@@ -185,7 +185,7 @@ public class FillDataTest {
excelWriter
.
finish
();
List
<
Object
>
list
=
EasyExcel
.
read
(
file
).
sheet
().
headRowNumber
(
3
).
doReadSync
();
Assert
.
assertEquals
(
list
.
size
(),
21L
);
Map
<
String
,
String
>
map19
=
(
Map
<
String
,
String
>)
list
.
get
(
19
);
Map
<
String
,
String
>
map19
=
(
Map
<
String
,
String
>)
list
.
get
(
19
);
Assert
.
assertEquals
(
"张三"
,
map19
.
get
(
0
));
}
...
...
@@ -203,6 +203,9 @@ public class FillDataTest {
list
.
add
(
fillData
);
fillData
.
setName
(
"张三"
);
fillData
.
setNumber
(
5.2
);
if
(
i
==
5
)
{
fillData
.
setName
(
null
);
}
}
return
list
;
}
...
...
update.md
浏览文件 @
fba1f72d
# 2.2.3
*
修改填充数据空数据的bug
[
Issue #1274
](
https://github.com/alibaba/easyexcel/issues/1274
)
*
回退自定义转换器入参为空
# 2.2.2
*
修改
`sheet`
事件未调用的bug
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录