Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
苏木力格
easyexcel
提交
be57f9ba
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,发现更多精彩内容 >>
提交
be57f9ba
编写于
4月 24, 2020
作者:
庄家钜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复填充的时候 多次`forceNewRow` 空指针的bug #1201
上级
ae63dd2a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
16 deletion
+50
-16
src/main/java/com/alibaba/excel/analysis/v03/XlsSaxAnalyser.java
...n/java/com/alibaba/excel/analysis/v03/XlsSaxAnalyser.java
+0
-5
src/main/java/com/alibaba/excel/analysis/v03/handlers/EofRecordHandler.java
...alibaba/excel/analysis/v03/handlers/EofRecordHandler.java
+22
-2
src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java
.../alibaba/excel/write/executor/ExcelWriteFillExecutor.java
+25
-8
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
+1
-1
update.md
update.md
+2
-0
未找到文件。
src/main/java/com/alibaba/excel/analysis/v03/XlsSaxAnalyser.java
浏览文件 @
be57f9ba
...
...
@@ -138,11 +138,6 @@ public class XlsSaxAnalyser implements HSSFListener, ExcelReadExecutor {
}
catch
(
IOException
e
)
{
throw
new
ExcelAnalysisException
(
e
);
}
// Sometimes tables lack the end record of the last column
if
(!
xlsReadContext
.
xlsReadSheetHolder
().
getCellMap
().
isEmpty
())
{
// Forge a termination data
processRecord
(
new
LastCellOfRowDummyRecord
(
xlsReadContext
.
xlsReadSheetHolder
().
getRowIndex
()
+
1
,
-
1
));
}
}
@Override
...
...
src/main/java/com/alibaba/excel/analysis/v03/handlers/EofRecordHandler.java
浏览文件 @
be57f9ba
package
com.alibaba.excel.analysis.v03.handlers
;
import
java.util.LinkedHashMap
;
import
org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord
;
import
org.apache.poi.hssf.record.Record
;
import
com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler
;
import
com.alibaba.excel.context.xls.XlsReadContext
;
import
com.alibaba.excel.enums.RowTypeEnum
;
import
com.alibaba.excel.metadata.Cell
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.read.metadata.holder.xls.XlsReadSheetHolder
;
/**
* Record handler
...
...
@@ -14,8 +21,21 @@ public class EofRecordHandler extends AbstractXlsRecordHandler implements Ignora
@Override
public
void
processRecord
(
XlsReadContext
xlsReadContext
,
Record
record
)
{
if
(
xlsReadContext
.
readSheetHolder
()
!=
null
)
{
xlsReadContext
.
analysisEventProcessor
().
endSheet
(
xlsReadContext
);
if
(
xlsReadContext
.
readSheetHolder
()
==
null
)
{
return
;
}
// Sometimes tables lack the end record of the last column
if
(!
xlsReadContext
.
xlsReadSheetHolder
().
getCellMap
().
isEmpty
())
{
XlsReadSheetHolder
xlsReadSheetHolder
=
xlsReadContext
.
xlsReadSheetHolder
();
// Forge a termination data
xlsReadContext
.
readRowHolder
(
new
ReadRowHolder
(
xlsReadContext
.
xlsReadSheetHolder
().
getRowIndex
()
+
1
,
xlsReadSheetHolder
.
getTempRowType
(),
xlsReadContext
.
readSheetHolder
().
getGlobalConfiguration
(),
xlsReadSheetHolder
.
getCellMap
()));
xlsReadContext
.
analysisEventProcessor
().
endRow
(
xlsReadContext
);
xlsReadSheetHolder
.
setCellMap
(
new
LinkedHashMap
<
Integer
,
Cell
>());
xlsReadSheetHolder
.
setTempRowType
(
RowTypeEnum
.
EMPTY
);
}
xlsReadContext
.
analysisEventProcessor
().
endSheet
(
xlsReadContext
);
}
}
src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java
浏览文件 @
be57f9ba
...
...
@@ -94,7 +94,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
Object
realData
;
if
(
data
instanceof
FillWrapper
)
{
FillWrapper
fillWrapper
=
(
FillWrapper
)
data
;
FillWrapper
fillWrapper
=
(
FillWrapper
)
data
;
currentDataPrefix
=
fillWrapper
.
getName
();
realData
=
fillWrapper
.
getCollectionData
();
}
else
{
...
...
@@ -106,7 +106,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
// processing data
if
(
realData
instanceof
Collection
)
{
List
<
AnalysisCell
>
analysisCellList
=
readTemplateData
(
templateCollectionAnalysisCache
);
Collection
collectionData
=
(
Collection
)
realData
;
Collection
collectionData
=
(
Collection
)
realData
;
if
(
CollectionUtils
.
isEmpty
(
collectionData
))
{
return
;
}
...
...
@@ -156,9 +156,23 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
return
;
}
sheet
.
shiftRows
(
maxRowIndex
+
1
,
lastRowIndex
,
number
,
true
,
false
);
for
(
AnalysisCell
analysisCell
:
templateAnalysisCache
.
get
(
currentUniqueDataFlag
))
{
if
(
analysisCell
.
getRowIndex
()
>
maxRowIndex
)
{
analysisCell
.
setRowIndex
(
analysisCell
.
getRowIndex
()
+
number
);
// The current data is greater than unity rowindex increase
String
tablePrefix
=
tablePrefix
(
currentUniqueDataFlag
);
increaseRowIndex
(
templateAnalysisCache
,
number
,
maxRowIndex
,
tablePrefix
);
increaseRowIndex
(
templateCollectionAnalysisCache
,
number
,
maxRowIndex
,
tablePrefix
);
}
private
void
increaseRowIndex
(
Map
<
String
,
List
<
AnalysisCell
>>
templateAnalysisCache
,
int
number
,
int
maxRowIndex
,
String
tablePrefix
)
{
for
(
Map
.
Entry
<
String
,
List
<
AnalysisCell
>>
entry
:
templateAnalysisCache
.
entrySet
())
{
if
(!
tablePrefix
.
equals
(
tablePrefix
(
entry
.
getKey
())))
{
continue
;
}
for
(
AnalysisCell
analysisCell
:
entry
.
getValue
())
{
if
(
analysisCell
.
getRowIndex
()
>
maxRowIndex
)
{
analysisCell
.
setRowIndex
(
analysisCell
.
getRowIndex
()
+
number
);
}
}
}
}
...
...
@@ -167,7 +181,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
Integer
relativeRowIndex
)
{
Map
dataMap
;
if
(
oneRowData
instanceof
Map
)
{
dataMap
=
(
Map
)
oneRowData
;
dataMap
=
(
Map
)
oneRowData
;
}
else
{
dataMap
=
BeanMap
.
create
(
oneRowData
);
}
...
...
@@ -384,8 +398,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
int
startIndex
=
0
;
int
length
=
value
.
length
();
int
lastPrepareDataIndex
=
0
;
out:
while
(
startIndex
<
length
)
{
out:
while
(
startIndex
<
length
)
{
int
prefixIndex
=
value
.
indexOf
(
FILL_PREFIX
,
startIndex
);
if
(
prefixIndex
<
0
)
{
break
out
;
...
...
@@ -515,4 +528,8 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
return
prefix
+
"-"
+
wrapperName
;
}
private
String
tablePrefix
(
String
uniqueDataFlag
)
{
return
uniqueDataFlag
.
substring
(
0
,
uniqueDataFlag
.
indexOf
(
"-"
)
+
1
);
}
}
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
浏览文件 @
be57f9ba
...
...
@@ -32,7 +32,7 @@ public class Lock2Test {
@Test
public
void
test
()
throws
Exception
{
File
file
=
new
File
(
"D:\\test\\headt1.xlsx
"
);
File
file
=
TestFileUtil
.
readUserHomeFile
(
"test/t3.xls
"
);
List
<
Object
>
list
=
EasyExcel
.
read
(
file
).
sheet
().
headRowNumber
(
0
).
doReadSync
();
LOGGER
.
info
(
"数据:{}"
,
list
.
size
());
...
...
update.md
浏览文件 @
be57f9ba
...
...
@@ -3,6 +3,8 @@
*
修复第一行为空不会调用
`invokeHeadMap`
的bug
[
Issue #993
](
https://github.com/alibaba/easyexcel/issues/993
)
*
当类的属性没有按照ExcelProperty的属性index顺序排序的时候,写数据出现错乱
[
Issue #1046
](
https://github.com/alibaba/easyexcel/issues/1046
)
*
新增支持自定义转换器 入参可以为空 实现
`NullableObjectConverter`
即可
[
Issue #1084
](
https://github.com/alibaba/easyexcel/issues/1084
)
*
修复xls丢失结束标记的情况下 会漏读最后一行
*
修复填充的时候 多次
`forceNewRow`
空指针的bug
[
Issue #1201
](
https://github.com/alibaba/easyexcel/issues/1201
)
# 2.2.0-beta2
*
修复最长匹配策略不同表格会有影响的bug
[
Issue #1010
](
https://github.com/alibaba/easyexcel/issues/1010
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录