Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_879456671
easyexcel
提交
06d3b4bb
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,发现更多精彩内容 >>
提交
06d3b4bb
编写于
9月 13, 2021
作者:
庄家钜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改单元测试
上级
316db1f2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
34 addition
and
54 deletion
+34
-54
src/main/java/com/alibaba/excel/metadata/AbstractHolder.java
src/main/java/com/alibaba/excel/metadata/AbstractHolder.java
+3
-7
src/main/java/com/alibaba/excel/metadata/GlobalConfiguration.java
.../java/com/alibaba/excel/metadata/GlobalConfiguration.java
+8
-30
src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java
...libaba/excel/read/metadata/holder/AbstractReadHolder.java
+9
-9
src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java
...baba/excel/write/metadata/holder/AbstractWriteHolder.java
+4
-7
src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationIndexAndNameDataTest.java
.../test/core/annotation/AnnotationIndexAndNameDataTest.java
+1
-1
src/test/java/com/alibaba/easyexcel/test/core/celldata/CellDataDataTest.java
...libaba/easyexcel/test/core/celldata/CellDataDataTest.java
+9
-0
未找到文件。
src/main/java/com/alibaba/excel/metadata/AbstractHolder.java
浏览文件 @
06d3b4bb
package
com.alibaba.excel.metadata
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
com.alibaba.excel.converters.Converter
;
...
...
@@ -55,19 +54,16 @@ public abstract class AbstractHolder implements ConfigurationHolder {
}
this
.
globalConfiguration
=
new
GlobalConfiguration
();
if
(
basicParameter
.
getAutoTrim
()
==
null
)
{
if
(
prentAbstractHolder
==
null
)
{
globalConfiguration
.
setAutoTrim
(
Boolean
.
TRUE
);
}
else
{
if
(
prentAbstractHolder
!=
null
)
{
globalConfiguration
.
setAutoTrim
(
prentAbstractHolder
.
getGlobalConfiguration
().
getAutoTrim
());
}
}
else
{
globalConfiguration
.
setAutoTrim
(
basicParameter
.
getAutoTrim
());
}
if
(
basicParameter
.
getLocale
()
==
null
)
{
if
(
prentAbstractHolder
==
null
)
{
globalConfiguration
.
setLocale
(
Locale
.
getDefault
());
}
else
{
if
(
prentAbstractHolder
!=
null
)
{
globalConfiguration
.
setLocale
(
prentAbstractHolder
.
getGlobalConfiguration
().
getLocale
());
}
}
else
{
...
...
src/main/java/com/alibaba/excel/metadata/GlobalConfiguration.java
浏览文件 @
06d3b4bb
...
...
@@ -2,11 +2,14 @@ package com.alibaba.excel.metadata;
import
java.util.Locale
;
import
lombok.Data
;
/**
* Global configuration
*
* @author Jiaju Zhuang
*/
@Data
public
class
GlobalConfiguration
{
/**
* Automatic trim includes sheet name and content
...
...
@@ -32,35 +35,10 @@ public class GlobalConfiguration {
*/
private
Boolean
useScientificFormat
;
public
Boolean
getUse1904windowing
()
{
return
use1904windowing
;
}
public
void
setUse1904windowing
(
Boolean
use1904windowing
)
{
this
.
use1904windowing
=
use1904windowing
;
}
public
Boolean
getAutoTrim
()
{
return
autoTrim
;
}
public
void
setAutoTrim
(
Boolean
autoTrim
)
{
this
.
autoTrim
=
autoTrim
;
}
public
Locale
getLocale
()
{
return
locale
;
}
public
void
setLocale
(
Locale
locale
)
{
this
.
locale
=
locale
;
}
public
Boolean
getUseScientificFormat
()
{
return
useScientificFormat
;
}
public
void
setUseScientificFormat
(
Boolean
useScientificFormat
)
{
this
.
useScientificFormat
=
useScientificFormat
;
public
GlobalConfiguration
()
{
this
.
autoTrim
=
Boolean
.
TRUE
;
this
.
use1904windowing
=
Boolean
.
FALSE
;
this
.
locale
=
Locale
.
getDefault
();
this
.
useScientificFormat
=
Boolean
.
FALSE
;
}
}
src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java
浏览文件 @
06d3b4bb
...
...
@@ -49,19 +49,20 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
public
AbstractReadHolder
(
ReadBasicParameter
readBasicParameter
,
AbstractReadHolder
parentAbstractReadHolder
,
Boolean
convertAllFiled
)
{
super
(
readBasicParameter
,
parentAbstractReadHolder
);
if
(
readBasicParameter
.
getUse1904windowing
()
==
null
&&
parentAbstractReadHolder
!=
null
)
{
getGlobalConfiguration
()
.
setUse1904windowing
(
parentAbstractReadHolder
.
getGlobalConfiguration
().
getUse1904windowing
());
if
(
readBasicParameter
.
getUse1904windowing
()
==
null
)
{
if
(
parentAbstractReadHolder
!=
null
)
{
getGlobalConfiguration
()
.
setUse1904windowing
(
parentAbstractReadHolder
.
getGlobalConfiguration
().
getUse1904windowing
());
}
}
else
{
getGlobalConfiguration
().
setUse1904windowing
(
readBasicParameter
.
getUse1904windowing
());
}
if
(
readBasicParameter
.
getUseScientificFormat
()
==
null
)
{
if
(
parentAbstractReadHolder
==
null
)
{
getGlobalConfiguration
().
setUseScientificFormat
(
Boolean
.
FALSE
);
}
else
{
getGlobalConfiguration
()
.
setUseScientificFormat
(
parentAbstractReadHolder
.
getGlobalConfiguration
().
getUseScientificFormat
());
if
(
parentAbstractReadHolder
!=
null
)
{
getGlobalConfiguration
().
setUseScientificFormat
(
parentAbstractReadHolder
.
getGlobalConfiguration
().
getUseScientificFormat
());
}
}
else
{
getGlobalConfiguration
().
setUseScientificFormat
(
readBasicParameter
.
getUseScientificFormat
());
...
...
@@ -114,7 +115,6 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
}
}
@Override
public
List
<
ReadListener
<?>>
readListenerList
()
{
return
getReadListenerList
();
...
...
src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java
浏览文件 @
06d3b4bb
...
...
@@ -96,10 +96,9 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
public
AbstractWriteHolder
(
WriteBasicParameter
writeBasicParameter
,
AbstractWriteHolder
parentAbstractWriteHolder
,
Boolean
convertAllField
)
{
super
(
writeBasicParameter
,
parentAbstractWriteHolder
);
if
(
writeBasicParameter
.
getUse1904windowing
()
==
null
)
{
if
(
parentAbstractWriteHolder
==
null
)
{
getGlobalConfiguration
().
setUse1904windowing
(
Boolean
.
FALSE
);
}
else
{
if
(
parentAbstractWriteHolder
!=
null
)
{
getGlobalConfiguration
()
.
setUse1904windowing
(
parentAbstractWriteHolder
.
getGlobalConfiguration
().
getUse1904windowing
());
}
...
...
@@ -210,7 +209,6 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
}
}
protected
void
initAnnotationConfig
(
List
<
WriteHandler
>
handlerList
,
WriteBasicParameter
writeBasicParameter
)
{
if
(!
HeadKindEnum
.
CLASS
.
equals
(
getExcelWriteHeadProperty
().
getHeadKind
()))
{
return
;
...
...
@@ -310,7 +308,6 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
handlerList
.
add
(
columnWidthStyleStrategy
);
}
protected
Map
<
Class
<?
extends
WriteHandler
>,
List
<
WriteHandler
>>
sortAndClearUpAllHandler
(
List
<
WriteHandler
>
handlerList
,
Map
<
Class
<?
extends
WriteHandler
>,
List
<
WriteHandler
>>
parentHandlerMap
)
{
// add
...
...
@@ -330,7 +327,7 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
for
(
WriteHandler
handler
:
handlerList
)
{
int
order
=
Integer
.
MIN_VALUE
;
if
(
handler
instanceof
Order
)
{
order
=
((
Order
)
handler
).
order
();
order
=
((
Order
)
handler
).
order
();
}
if
(
orderExcelWriteHandlerMap
.
containsKey
(
order
))
{
orderExcelWriteHandlerMap
.
get
(
order
).
add
(
handler
);
...
...
@@ -346,7 +343,7 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
for
(
Map
.
Entry
<
Integer
,
List
<
WriteHandler
>>
entry
:
orderExcelWriteHandlerMap
.
entrySet
())
{
for
(
WriteHandler
handler
:
entry
.
getValue
())
{
if
(
handler
instanceof
NotRepeatExecutor
)
{
String
uniqueValue
=
((
NotRepeatExecutor
)
handler
).
uniqueValue
();
String
uniqueValue
=
((
NotRepeatExecutor
)
handler
).
uniqueValue
();
if
(
alreadyExistedHandlerSet
.
contains
(
uniqueValue
))
{
continue
;
}
...
...
src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationIndexAndNameDataTest.java
浏览文件 @
06d3b4bb
...
...
@@ -39,7 +39,7 @@ public class AnnotationIndexAndNameDataTest {
}
@Test
public
void
t03ReadAndWrite
03
()
{
public
void
t03ReadAndWrite
Csv
()
{
readAndWrite
(
fileCsv
);
}
...
...
src/test/java/com/alibaba/easyexcel/test/core/celldata/CellDataDataTest.java
浏览文件 @
06d3b4bb
...
...
@@ -25,11 +25,14 @@ public class CellDataDataTest {
private
static
File
file07
;
private
static
File
file03
;
private
static
File
fileCsv
;
@BeforeClass
public
static
void
init
()
{
file07
=
TestFileUtil
.
createNewFile
(
"cellData07.xlsx"
);
file03
=
TestFileUtil
.
createNewFile
(
"cellData03.xls"
);
fileCsv
=
TestFileUtil
.
createNewFile
(
"cellDataCsv.csv"
);
}
@Test
...
...
@@ -42,6 +45,12 @@ public class CellDataDataTest {
readAndWrite
(
file03
);
}
@Test
public
void
t03ReadAndWriteCsv
()
throws
Exception
{
readAndWrite
(
fileCsv
);
}
private
void
readAndWrite
(
File
file
)
throws
Exception
{
EasyExcel
.
write
(
file
,
CellDataWriteData
.
class
).
sheet
().
doWrite
(
data
());
EasyExcel
.
read
(
file
,
CellDataReadData
.
class
,
new
CellDataDataListener
()).
sheet
().
doRead
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录