Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
苏木力格
easyexcel
提交
cebc5217
E
easyexcel
项目概览
苏木力格
/
easyexcel
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
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,发现更多精彩内容 >>
提交
cebc5217
编写于
3月 16, 2021
作者:
是
是仪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
兼容07在特殊的excel的情况下,读取数据异常
上级
bb316634
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
20 addition
and
6 deletion
+20
-6
pom.xml
pom.xml
+1
-1
src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractCellValueTagHandler.java
...el/analysis/v07/handlers/AbstractCellValueTagHandler.java
+10
-0
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellValueTagHandler.java
...baba/excel/analysis/v07/handlers/CellValueTagHandler.java
+5
-0
src/test/java/com/alibaba/easyexcel/test/temp/LockTest.java
src/test/java/com/alibaba/easyexcel/test/temp/LockTest.java
+1
-5
update.md
update.md
+3
-0
未找到文件。
pom.xml
浏览文件 @
cebc5217
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.alibaba
</groupId>
<groupId>
com.alibaba
</groupId>
<artifactId>
easyexcel
</artifactId>
<artifactId>
easyexcel
</artifactId>
<version>
2.2.
7
</version>
<version>
2.2.
8
</version>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<name>
easyexcel
</name>
<name>
easyexcel
</name>
...
...
src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractCellValueTagHandler.java
浏览文件 @
cebc5217
...
@@ -7,6 +7,7 @@ import com.alibaba.excel.enums.CellDataTypeEnum;
...
@@ -7,6 +7,7 @@ import com.alibaba.excel.enums.CellDataTypeEnum;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder
;
import
com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder
;
import
com.alibaba.excel.util.BooleanUtils
;
import
com.alibaba.excel.util.BooleanUtils
;
import
com.alibaba.excel.util.StringUtils
;
/**
/**
* Cell Value Handler
* Cell Value Handler
...
@@ -20,6 +21,7 @@ public abstract class AbstractCellValueTagHandler extends AbstractXlsxTagHandler
...
@@ -20,6 +21,7 @@ public abstract class AbstractCellValueTagHandler extends AbstractXlsxTagHandler
XlsxReadSheetHolder
xlsxReadSheetHolder
=
xlsxReadContext
.
xlsxReadSheetHolder
();
XlsxReadSheetHolder
xlsxReadSheetHolder
=
xlsxReadContext
.
xlsxReadSheetHolder
();
CellData
tempCellData
=
xlsxReadSheetHolder
.
getTempCellData
();
CellData
tempCellData
=
xlsxReadSheetHolder
.
getTempCellData
();
StringBuilder
tempData
=
xlsxReadSheetHolder
.
getTempData
();
StringBuilder
tempData
=
xlsxReadSheetHolder
.
getTempData
();
String
tempDataString
=
tempData
.
toString
();
CellDataTypeEnum
oldType
=
tempCellData
.
getType
();
CellDataTypeEnum
oldType
=
tempCellData
.
getType
();
switch
(
oldType
)
{
switch
(
oldType
)
{
case
DIRECT_STRING:
case
DIRECT_STRING:
...
@@ -28,10 +30,18 @@ public abstract class AbstractCellValueTagHandler extends AbstractXlsxTagHandler
...
@@ -28,10 +30,18 @@ public abstract class AbstractCellValueTagHandler extends AbstractXlsxTagHandler
tempCellData
.
setStringValue
(
tempData
.
toString
());
tempCellData
.
setStringValue
(
tempData
.
toString
());
break
;
break
;
case
BOOLEAN:
case
BOOLEAN:
if
(
StringUtils
.
isEmpty
(
tempDataString
)){
tempCellData
.
setType
(
CellDataTypeEnum
.
EMPTY
);
break
;
}
tempCellData
.
setBooleanValue
(
BooleanUtils
.
valueOf
(
tempData
.
toString
()));
tempCellData
.
setBooleanValue
(
BooleanUtils
.
valueOf
(
tempData
.
toString
()));
break
;
break
;
case
NUMBER:
case
NUMBER:
case
EMPTY:
case
EMPTY:
if
(
StringUtils
.
isEmpty
(
tempDataString
)){
tempCellData
.
setType
(
CellDataTypeEnum
.
EMPTY
);
break
;
}
tempCellData
.
setType
(
CellDataTypeEnum
.
NUMBER
);
tempCellData
.
setType
(
CellDataTypeEnum
.
NUMBER
);
tempCellData
.
setNumberValue
(
new
BigDecimal
(
tempData
.
toString
()));
tempCellData
.
setNumberValue
(
new
BigDecimal
(
tempData
.
toString
()));
break
;
break
;
...
...
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellValueTagHandler.java
浏览文件 @
cebc5217
...
@@ -3,6 +3,7 @@ package com.alibaba.excel.analysis.v07.handlers;
...
@@ -3,6 +3,7 @@ package com.alibaba.excel.analysis.v07.handlers;
import
com.alibaba.excel.context.xlsx.XlsxReadContext
;
import
com.alibaba.excel.context.xlsx.XlsxReadContext
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.util.StringUtils
;
/**
/**
* Cell Value Handler
* Cell Value Handler
...
@@ -17,6 +18,10 @@ public class CellValueTagHandler extends AbstractCellValueTagHandler {
...
@@ -17,6 +18,10 @@ public class CellValueTagHandler extends AbstractCellValueTagHandler {
CellData
tempCellData
=
xlsxReadContext
.
xlsxReadSheetHolder
().
getTempCellData
();
CellData
tempCellData
=
xlsxReadContext
.
xlsxReadSheetHolder
().
getTempCellData
();
switch
(
tempCellData
.
getType
())
{
switch
(
tempCellData
.
getType
())
{
case
STRING:
case
STRING:
// In some cases, although cell type is a string, it may be an empty tag
if
(
StringUtils
.
isEmpty
(
tempCellData
.
getStringValue
())){
break
;
}
String
stringValue
=
xlsxReadContext
.
readWorkbookHolder
().
getReadCache
()
String
stringValue
=
xlsxReadContext
.
readWorkbookHolder
().
getReadCache
()
.
get
(
Integer
.
valueOf
(
tempCellData
.
getStringValue
()));
.
get
(
Integer
.
valueOf
(
tempCellData
.
getStringValue
()));
if
(
stringValue
!=
null
&&
xlsxReadContext
.
currentReadHolder
().
globalConfiguration
().
getAutoTrim
())
{
if
(
stringValue
!=
null
&&
xlsxReadContext
.
currentReadHolder
().
globalConfiguration
().
getAutoTrim
())
{
...
...
src/test/java/com/alibaba/easyexcel/test/temp/LockTest.java
浏览文件 @
cebc5217
...
@@ -26,11 +26,7 @@ public class LockTest {
...
@@ -26,11 +26,7 @@ public class LockTest {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
List
<
Object
>
list
=
List
<
Object
>
list
=
EasyExcel
.
read
(
new
FileInputStream
(
"D:\\test\\testbug嘉惠.xlsx"
)).
sheet
().
headRowNumber
(
0
).
doReadSync
();
EasyExcel
.
read
(
new
FileInputStream
(
"/Users/zhuangjiaju/Downloads/点位配置表 (1).xlsx"
)).
doReadAllSync
();
for
(
Object
data
:
list
)
{
LOGGER
.
info
(
"返回数据:{}"
,
JSON
.
toJSONString
(
data
));
}
list
=
EasyExcel
.
read
(
new
File
(
"D:\\test\\t222.xlsx"
)).
sheet
().
headRowNumber
(
0
).
doReadSync
();
for
(
Object
data
:
list
)
{
for
(
Object
data
:
list
)
{
LOGGER
.
info
(
"返回数据:{}"
,
JSON
.
toJSONString
(
data
));
LOGGER
.
info
(
"返回数据:{}"
,
JSON
.
toJSONString
(
data
));
}
}
...
...
update.md
浏览文件 @
cebc5217
# 2.2.8
*
兼容07在特殊的excel的情况下,读取数据异常
# 2.2.7
# 2.2.7
*
修改07在特殊情况下用
`String`
接收数字会丢小数位的bug
*
修改07在特殊情况下用
`String`
接收数字会丢小数位的bug
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录