Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_879456671
easyexcel
提交
852f0eca
E
easyexcel
项目概览
qq_879456671
/
easyexcel
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
852f0eca
编写于
5月 22, 2020
作者:
庄家钜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复多个`sheet`不按照顺序写入 会错误的bug #1332
上级
737de955
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
83 addition
and
6 deletion
+83
-6
src/main/java/com/alibaba/excel/context/WriteContextImpl.java
...main/java/com/alibaba/excel/context/WriteContextImpl.java
+14
-5
src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java
...baba/excel/write/metadata/holder/WriteWorkbookHolder.java
+1
-0
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
+1
-1
src/test/java/com/alibaba/easyexcel/test/temp/WriteV33Test.java
...st/java/com/alibaba/easyexcel/test/temp/WriteV33Test.java
+64
-0
update.md
update.md
+3
-0
未找到文件。
src/main/java/com/alibaba/excel/context/WriteContextImpl.java
浏览文件 @
852f0eca
...
...
@@ -112,7 +112,6 @@ public class WriteContextImpl implements WriteContext {
return
;
}
initCurrentSheetHolder
(
writeSheet
);
// Workbook handler need to supplementary execution
...
...
@@ -125,7 +124,11 @@ public class WriteContextImpl implements WriteContext {
private
boolean
selectSheetFromCache
(
WriteSheet
writeSheet
)
{
writeSheetHolder
=
null
;
if
(
writeSheet
.
getSheetNo
()
!=
null
)
{
Integer
sheetNo
=
null
;
if
(
writeSheet
.
getSheetNo
()
==
null
&&
StringUtils
.
isEmpty
(
writeSheet
.
getSheetName
()))
{
sheetNo
=
0
;
}
if
(
sheetNo
!=
null
)
{
writeSheetHolder
=
writeWorkbookHolder
.
getHasBeenInitializedSheetIndexMap
().
get
(
writeSheet
.
getSheetNo
());
}
if
(
writeSheetHolder
==
null
&&
!
StringUtils
.
isEmpty
(
writeSheet
.
getSheetName
()))
{
...
...
@@ -160,9 +163,15 @@ public class WriteContextImpl implements WriteContext {
Sheet
currentSheet
;
try
{
if
(
writeSheetHolder
.
getSheetNo
()
!=
null
)
{
currentSheet
=
writeWorkbookHolder
.
getWorkbook
().
getSheetAt
(
writeSheetHolder
.
getSheetNo
());
int
realSheetNo
=
writeSheetHolder
.
getSheetNo
();
// When the add default sort order of appearance
if
(
WriteTypeEnum
.
ADD
.
equals
(
writeType
))
{
currentSheet
=
createSheet
();
}
else
{
currentSheet
=
writeWorkbookHolder
.
getWorkbook
().
getSheetAt
(
realSheetNo
);
writeSheetHolder
.
setCachedSheet
(
writeWorkbookHolder
.
getCachedWorkbook
().
getSheetAt
(
writeSheetHolder
.
getSheetNo
()));
.
setCachedSheet
(
writeWorkbookHolder
.
getCachedWorkbook
().
getSheetAt
(
realSheetNo
));
}
}
else
{
// sheet name must not null
currentSheet
=
writeWorkbookHolder
.
getWorkbook
().
getSheet
(
writeSheetHolder
.
getSheetName
());
...
...
src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java
浏览文件 @
852f0eca
...
...
@@ -112,6 +112,7 @@ public class WriteWorkbookHolder extends AbstractWriteHolder {
*/
private
Boolean
writeExcelOnException
;
public
WriteWorkbookHolder
(
WriteWorkbook
writeWorkbook
)
{
super
(
writeWorkbook
,
null
,
writeWorkbook
.
getConvertAllFiled
());
this
.
writeWorkbook
=
writeWorkbook
;
...
...
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
浏览文件 @
852f0eca
...
...
@@ -32,7 +32,7 @@ public class Lock2Test {
@Test
public
void
test
()
throws
Exception
{
File
file
=
TestFileUtil
.
readUserHomeFile
(
"test/test
2style.xls
"
);
File
file
=
TestFileUtil
.
readUserHomeFile
(
"test/test
.xlsx
"
);
List
<
Object
>
list
=
EasyExcel
.
read
(
file
).
ignoreEmptyRow
(
true
).
sheet
().
headRowNumber
(
0
).
doReadSync
();
LOGGER
.
info
(
"数据:{}"
,
list
.
size
());
...
...
src/test/java/com/alibaba/easyexcel/test/temp/WriteV33Test.java
0 → 100644
浏览文件 @
852f0eca
package
com.alibaba.easyexcel.test.temp
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.poi.hssf.util.CellReference
;
import
org.apache.poi.ss.usermodel.FillPatternType
;
import
org.apache.poi.ss.usermodel.IndexedColors
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.alibaba.easyexcel.test.demo.write.DemoData
;
import
com.alibaba.easyexcel.test.util.TestFileUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.alibaba.excel.write.metadata.style.WriteCellStyle
;
import
com.alibaba.excel.write.metadata.style.WriteFont
;
import
com.alibaba.excel.write.style.HorizontalCellStyleStrategy
;
import
com.alibaba.fastjson.JSON
;
/**
* 临时测试
*
* @author Jiaju Zhuang
**/
@Ignore
public
class
WriteV33Test
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
WriteV33Test
.
class
);
@Test
public
void
test
()
throws
Exception
{
// 方法2 如果写到不同的sheet 同一个对象
String
fileName
=
TestFileUtil
.
getPath
()
+
"repeatedWrite"
+
System
.
currentTimeMillis
()
+
".xlsx"
;
// 这里 指定文件
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
fileName
,
DemoData
.
class
).
build
();
WriteSheet
writeSheet1
=
EasyExcel
.
writerSheet
(
1
,
"模板1"
).
build
();
WriteSheet
writeSheet2
=
EasyExcel
.
writerSheet
(
2
,
"模板2"
).
build
();
WriteSheet
writeSheet3
=
EasyExcel
.
writerSheet
(
3
,
"模板3"
).
build
();
excelWriter
.
write
(
data
(
2
),
writeSheet2
);
excelWriter
.
write
(
data
(
3
),
writeSheet3
);
excelWriter
.
write
(
data
(
1
),
writeSheet1
);
excelWriter
.
write
(
data
(
3
),
writeSheet3
);
excelWriter
.
write
(
data
(
1
),
writeSheet1
);
/// 千万别忘记finish 会帮忙关闭流
excelWriter
.
finish
();
}
private
List
<
DemoData
>
data
(
int
no
)
{
List
<
DemoData
>
list
=
new
ArrayList
<
DemoData
>();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
DemoData
data
=
new
DemoData
();
data
.
setString
(
"字符串"
+
no
+
"---"
+
i
);
list
.
add
(
data
);
}
return
list
;
}
}
update.md
浏览文件 @
852f0eca
...
...
@@ -2,6 +2,9 @@
*
撤销删除
`AbstractMergeStrategy`
*
修改默认用String读取数字不使用科学计数法 通过
`useScientificFormat`
修改
*
修复07版仅有样式的空行 默认不忽略的bug
*
写入
`sheet`
不设置
`index`
和
`name`
默认不为0的问题
*
修复多个
`sheet`
不按照顺序写入 会错误的bug
[
Issue #1332
](
https://github.com/alibaba/easyexcel/issues/1332
)
# 2.2.3
*
修改填充数据空数据的bug
[
Issue #1274
](
https://github.com/alibaba/easyexcel/issues/1274
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录