Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Laubin729
easyexcel
提交
3fa9285c
E
easyexcel
项目概览
Laubin729
/
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,发现更多精彩内容 >>
提交
3fa9285c
编写于
9月 26, 2019
作者:
庄家钜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化07版超大文件读取参数配置
上级
aede58f4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
136 addition
and
7 deletion
+136
-7
src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
.../java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
+1
-1
src/main/java/com/alibaba/excel/cache/Ehcache.java
src/main/java/com/alibaba/excel/cache/Ehcache.java
+12
-4
src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java
...baba/excel/write/metadata/holder/WriteWorkbookHolder.java
+0
-2
src/test/java/com/alibaba/easyexcel/test/temp/large/LargeData.java
...java/com/alibaba/easyexcel/test/temp/large/LargeData.java
+60
-0
src/test/java/com/alibaba/easyexcel/test/temp/large/LargeDataListener.java
.../alibaba/easyexcel/test/temp/large/LargeDataListener.java
+33
-0
src/test/java/com/alibaba/easyexcel/test/temp/large/LargeDataTest.java
.../com/alibaba/easyexcel/test/temp/large/LargeDataTest.java
+26
-0
update.md
update.md
+4
-0
未找到文件。
src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
浏览文件 @
3fa9285c
...
@@ -103,7 +103,7 @@ public class XlsxSaxAnalyser implements ExcelExecutor {
...
@@ -103,7 +103,7 @@ public class XlsxSaxAnalyser implements ExcelExecutor {
if
(
size
<
0
)
{
if
(
size
<
0
)
{
size
=
sharedStringsTablePackagePart
.
getInputStream
().
available
();
size
=
sharedStringsTablePackagePart
.
getInputStream
().
available
();
}
}
if
(
size
<
USE_MAP_CACHE_SIZE
)
{
if
(
size
<
readWorkbookHolder
.
getSharedStringsUseEhcacheSize
()
)
{
if
(
LOGGER
.
isDebugEnabled
())
{
if
(
LOGGER
.
isDebugEnabled
())
{
LOGGER
.
debug
(
"Use map cache.size:{}"
,
size
);
LOGGER
.
debug
(
"Use map cache.size:{}"
,
size
);
}
}
...
...
src/main/java/com/alibaba/excel/cache/Ehcache.java
浏览文件 @
3fa9285c
...
@@ -32,9 +32,7 @@ public class Ehcache implements ReadCache {
...
@@ -32,9 +32,7 @@ public class Ehcache implements ReadCache {
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Ehcache
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Ehcache
.
class
);
private
static
final
int
BATCH_COUNT
=
1000
;
private
static
final
int
BATCH_COUNT
=
1000
;
private
static
final
int
CHECK_INTERVAL
=
500
;
private
static
final
int
CHECK_INTERVAL
=
1000
;
private
static
final
int
MAX_CACHE_ACTIVATE
=
10
;
private
static
final
String
CACHE
=
"cache"
;
private
static
final
String
CACHE
=
"cache"
;
private
static
final
String
DATA_SEPARATOR
=
"@"
;
private
static
final
String
DATA_SEPARATOR
=
"@"
;
private
static
final
String
KEY_VALUE_SEPARATOR
=
"!"
;
private
static
final
String
KEY_VALUE_SEPARATOR
=
"!"
;
...
@@ -50,6 +48,10 @@ public class Ehcache implements ReadCache {
...
@@ -50,6 +48,10 @@ public class Ehcache implements ReadCache {
* Key index
* Key index
*/
*/
private
int
index
=
0
;
private
int
index
=
0
;
/**
* Maximum number of cache activation
*/
private
int
maxCacheActivate
=
100
;
private
StringBuilder
data
=
new
StringBuilder
();
private
StringBuilder
data
=
new
StringBuilder
();
private
CacheManager
cacheManager
;
private
CacheManager
cacheManager
;
/**
/**
...
@@ -80,6 +82,12 @@ public class Ehcache implements ReadCache {
...
@@ -80,6 +82,12 @@ public class Ehcache implements ReadCache {
*/
*/
private
int
cacheMiss
=
0
;
private
int
cacheMiss
=
0
;
public
Ehcache
()
{}
public
Ehcache
(
int
maxCacheActivate
)
{
this
.
maxCacheActivate
=
maxCacheActivate
;
}
@Override
@Override
public
void
init
(
AnalysisContext
analysisContext
)
{
public
void
init
(
AnalysisContext
analysisContext
)
{
File
readTempFile
=
analysisContext
.
readWorkbookHolder
().
getTempFile
();
File
readTempFile
=
analysisContext
.
readWorkbookHolder
().
getTempFile
();
...
@@ -166,7 +174,7 @@ public class Ehcache implements ReadCache {
...
@@ -166,7 +174,7 @@ public class Ehcache implements ReadCache {
}
}
private
void
checkClear
()
{
private
void
checkClear
()
{
if
(
countList
.
size
()
>
MAX_CACHE_ACTIVATE
)
{
if
(
countList
.
size
()
>
maxCacheActivate
)
{
Integer
route
=
countList
.
getFirst
();
Integer
route
=
countList
.
getFirst
();
countList
.
removeFirst
();
countList
.
removeFirst
();
cacheMap
.
remove
(
route
);
cacheMap
.
remove
(
route
);
...
...
src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java
浏览文件 @
3fa9285c
...
@@ -10,8 +10,6 @@ import java.util.HashMap;
...
@@ -10,8 +10,6 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.alibaba.excel.enums.HolderEnum
;
import
com.alibaba.excel.enums.HolderEnum
;
import
com.alibaba.excel.exception.ExcelGenerateException
;
import
com.alibaba.excel.exception.ExcelGenerateException
;
...
...
src/test/java/com/alibaba/easyexcel/test/temp/large/LargeData.java
0 → 100644
浏览文件 @
3fa9285c
package
com.alibaba.easyexcel.test.temp.large
;
import
lombok.Data
;
/**
* @author Jiaju Zhuang
*/
@Data
public
class
LargeData
{
private
String
str1
;
private
String
str2
;
private
String
str3
;
private
String
str4
;
private
String
str5
;
private
String
str6
;
private
String
str7
;
private
String
str8
;
private
String
str9
;
private
String
str10
;
private
String
str11
;
private
String
str12
;
private
String
str13
;
private
String
str14
;
private
String
str15
;
private
String
str16
;
private
String
str17
;
private
String
str18
;
private
String
str19
;
private
String
str20
;
private
String
str21
;
private
String
str22
;
private
String
str23
;
private
String
str24
;
private
String
str25
;
}
src/test/java/com/alibaba/easyexcel/test/temp/large/LargeDataListener.java
0 → 100644
浏览文件 @
3fa9285c
package
com.alibaba.easyexcel.test.temp.large
;
import
org.junit.Assert
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.fastjson.JSON
;
/**
* @author Jiaju Zhuang
*/
public
class
LargeDataListener
extends
AnalysisEventListener
<
LargeData
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
LargeDataListener
.
class
);
private
int
count
=
0
;
@Override
public
void
invoke
(
LargeData
data
,
AnalysisContext
context
)
{
if
(
count
==
0
)
{
LOGGER
.
info
(
"First row:{}"
,
JSON
.
toJSONString
(
data
));
}
count
++;
if
(
count
%
100000
==
0
)
{
LOGGER
.
info
(
"Already read:{}"
,
count
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
LOGGER
.
info
(
"Large row count:{}"
,
count
);
}
}
src/test/java/com/alibaba/easyexcel/test/temp/large/LargeDataTest.java
0 → 100644
浏览文件 @
3fa9285c
package
com.alibaba.easyexcel.test.temp.large
;
import
java.io.FileInputStream
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.cache.MapCache
;
/**
*
* @author Jiaju Zhuang
*/
public
class
LargeDataTest
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
LargeDataTest
.
class
);
@Test
public
void
read
()
throws
Exception
{
long
start
=
System
.
currentTimeMillis
();
EasyExcel
.
read
(
new
FileInputStream
(
"D:\\test\\MRP生产视图(1).xlsx"
),
LargeData
.
class
,
new
LargeDataListener
()).
readCache
(
new
eh
)
.
headRowNumber
(
2
).
sheet
().
doRead
();
LOGGER
.
info
(
"Large data total time spent:{}"
,
System
.
currentTimeMillis
()
-
start
);
}
}
update.md
浏览文件 @
3fa9285c
# 2.0.5
*
优化07版超大文件读取参数配置
*
支持自己设置超大文件读取参数
# 2.0.4
# 2.0.4
*
修复07版整个excel仅存在数字时会出现的NPE
*
修复07版整个excel仅存在数字时会出现的NPE
*
修复03版 用String接收电话会出现科学计数法的问题
*
修复03版 用String接收电话会出现科学计数法的问题
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录