Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
1c7a5faa
Commit
1c7a5faa
authored
Dec 03, 2020
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Excel支持注解align对齐方式
parent
23868c4f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
...mmon/src/main/java/com/ruoyi/common/annotation/Excel.java
+21
-0
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+17
-1
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
View file @
1c7a5faa
...
@@ -105,6 +105,27 @@ public @interface Excel
...
@@ -105,6 +105,27 @@ public @interface Excel
*/
*/
public
boolean
isStatistics
()
default
false
;
public
boolean
isStatistics
()
default
false
;
/**
* 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
*/
Align
align
()
default
Align
.
AUTO
;
public
enum
Align
{
AUTO
(
0
),
LEFT
(
1
),
CENTER
(
2
),
RIGHT
(
3
);
private
final
int
value
;
Align
(
int
value
)
{
this
.
value
=
value
;
}
public
int
value
()
{
return
this
.
value
;
}
}
/**
/**
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
*/
*/
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
View file @
1c7a5faa
...
@@ -473,6 +473,21 @@ public class ExcelUtil<T>
...
@@ -473,6 +473,21 @@ public class ExcelUtil<T>
style
.
setFont
(
totalFont
);
style
.
setFont
(
totalFont
);
styles
.
put
(
"total"
,
style
);
styles
.
put
(
"total"
,
style
);
style
=
wb
.
createCellStyle
();
style
.
cloneStyleFrom
(
styles
.
get
(
"data"
));
style
.
setAlignment
(
HorizontalAlignment
.
LEFT
);
styles
.
put
(
"data1"
,
style
);
style
=
wb
.
createCellStyle
();
style
.
cloneStyleFrom
(
styles
.
get
(
"data"
));
style
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
styles
.
put
(
"data2"
,
style
);
style
=
wb
.
createCellStyle
();
style
.
cloneStyleFrom
(
styles
.
get
(
"data"
));
style
.
setAlignment
(
HorizontalAlignment
.
RIGHT
);
styles
.
put
(
"data3"
,
style
);
return
styles
;
return
styles
;
}
}
...
@@ -555,7 +570,8 @@ public class ExcelUtil<T>
...
@@ -555,7 +570,8 @@ public class ExcelUtil<T>
{
{
// 创建cell
// 创建cell
cell
=
row
.
createCell
(
column
);
cell
=
row
.
createCell
(
column
);
cell
.
setCellStyle
(
styles
.
get
(
"data"
));
int
align
=
attr
.
align
().
value
();
cell
.
setCellStyle
(
styles
.
get
(
"data"
+
(
align
>=
1
&&
align
<=
3
?
align
:
""
)));
// 用于读取对象中的属性
// 用于读取对象中的属性
Object
value
=
getTargetValue
(
vo
,
field
,
attr
);
Object
value
=
getTargetValue
(
vo
,
field
,
attr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment