Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyang
sts网站
Commits
188e50ff
Commit
188e50ff
authored
Dec 04, 2025
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持Excel导出对象的多个子列表
parent
bd66cc72
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+10
-6
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
View file @
188e50ff
...
...
@@ -174,12 +174,12 @@ public class ExcelUtil<T>
/**
* 对象的子列表方法
*/
private
Map
<
String
,
Method
>
subMethods
=
new
HashMap
<>()
;
private
Map
<
String
,
Method
>
subMethods
;
/**
* 对象的子列表属性
*/
private
Map
<
String
,
List
<
Field
>>
subFieldsMap
=
new
HashMap
<>()
;
private
Map
<
String
,
List
<
Field
>>
subFieldsMap
;
/**
* 统计列表
...
...
@@ -252,7 +252,10 @@ public class ExcelUtil<T>
int
titleLastCol
=
this
.
fields
.
size
()
-
1
;
if
(
isSubList
())
{
titleLastCol
=
titleLastCol
+
subFieldsMap
.
values
().
size
()
-
1
;
for
(
List
<
Field
>
currentSubFields
:
subFieldsMap
.
values
())
{
titleLastCol
=
titleLastCol
+
currentSubFields
.
size
()
-
1
;
}
}
Row
titleRow
=
sheet
.
createRow
(
rownum
==
0
?
rownum
++
:
0
);
titleRow
.
setHeightInPoints
(
30
);
...
...
@@ -722,7 +725,6 @@ public class ExcelUtil<T>
* 填充excel数据
*
* @param index 序号
* @param row 单元格行
*/
@SuppressWarnings
(
"unchecked"
)
public
void
fillExcelData
(
int
index
)
...
...
@@ -746,10 +748,10 @@ public class ExcelUtil<T>
try
{
Collection
<?>
subList
=
(
Collection
<?>)
getTargetValue
(
vo
,
field
,
excel
);
List
<
Field
>
currentSubFields
=
subFieldsMap
.
get
(
field
.
getName
());
if
(
subList
!=
null
&&
!
subList
.
isEmpty
())
{
int
subIndex
=
0
;
List
<
Field
>
currentSubFields
=
subFieldsMap
.
get
(
field
.
getName
());
for
(
Object
subVo
:
subList
)
{
Row
subRow
=
sheet
.
getRow
(
currentRowNum
+
subIndex
);
...
...
@@ -766,8 +768,8 @@ public class ExcelUtil<T>
}
subIndex
++;
}
column
+=
currentSubFields
.
size
();
}
column
+=
currentSubFields
.
size
();
}
catch
(
Exception
e
)
{
...
...
@@ -1558,6 +1560,8 @@ public class ExcelUtil<T>
{
List
<
Object
[]>
fields
=
new
ArrayList
<
Object
[]>();
List
<
Field
>
tempFields
=
new
ArrayList
<>();
subFieldsMap
=
new
HashMap
<>();
subMethods
=
new
HashMap
<>();
tempFields
.
addAll
(
Arrays
.
asList
(
clazz
.
getSuperclass
().
getDeclaredFields
()));
tempFields
.
addAll
(
Arrays
.
asList
(
clazz
.
getDeclaredFields
()));
if
(
StringUtils
.
isNotEmpty
(
includeFields
))
...
...
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