Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
2dcdf475
Commit
2dcdf475
authored
Oct 10, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口文档的支持
parent
7e9a4574
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
19 deletions
+22
-19
ExcelConsole.java
...-db/src/main/java/com/yanzuoguang/excel/ExcelConsole.java
+11
-1
ExcelMergerData.java
.../src/main/java/com/yanzuoguang/excel/ExcelMergerData.java
+11
-18
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExcelConsole.java
View file @
2dcdf475
...
...
@@ -301,7 +301,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
if
(
column
.
isMerger
())
{
ExcelMergerData
mergerData
=
mergerGroupData
.
get
(
column
.
getMegerGroup
());
// 判断是否需要合并历史记录
if
(
mergerData
.
getRowCell
()
>
1
)
{
if
(
mergerData
.
isMergerFlag
()
)
{
// 合并历史记录单元格
mergerData
(
mergerData
,
columnPos
);
}
...
...
@@ -320,6 +320,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
private
void
mergerData
(
ExcelMergerData
mergerColumn
,
int
columnPos
)
{
int
rowStart
=
mergerColumn
.
getRowIndex
();
int
rowEnd
=
rowStart
+
mergerColumn
.
getRowCell
()
-
1
;
CellRangeAddress
region
=
new
CellRangeAddress
(
rowStart
,
rowEnd
,
columnPos
,
columnPos
);
sheet
.
addMergedRegion
(
region
);
...
...
@@ -337,6 +338,15 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
// 合并数据配置
for
(
int
columnPos
=
0
;
columnPos
<
this
.
config
.
getColumns
().
size
();
columnPos
++)
{
ExportColumn
column
=
this
.
config
.
getColumns
().
get
(
columnPos
);
// 判断列是否需要合并
if
(
column
.
isMerger
())
{
ExcelMergerData
mergerData
=
mergerGroupData
.
get
(
column
.
getMegerGroup
());
// 判断是否需要合并历史记录
if
(
mergerData
.
isMergerFlag
())
{
// 合并历史记录单元格
mergerData
(
mergerData
,
columnPos
);
}
}
if
(
column
.
getWidth
()
<
1
)
{
sheet
.
autoSizeColumn
(
columnPos
,
true
);
}
else
{
...
...
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExcelMergerData.java
View file @
2dcdf475
...
...
@@ -24,6 +24,11 @@ public class ExcelMergerData {
*/
private
int
rowCell
=
1
;
/**
* 判断是否可以合并
*/
private
boolean
mergerFlag
=
false
;
/**
* 上次合并行号
*/
...
...
@@ -50,6 +55,8 @@ public class ExcelMergerData {
this
.
data
=
nowCellData
;
this
.
rowIndex
=
rowIndex
;
this
.
rowCell
=
1
;
this
.
mergerFlag
=
true
;
}
else
{
this
.
rowCell
++;
}
...
...
@@ -59,39 +66,25 @@ public class ExcelMergerData {
return
data
;
}
public
void
setData
(
String
data
)
{
this
.
data
=
data
;
}
public
int
getRowIndex
()
{
return
rowIndex
;
}
public
void
setRowIndex
(
int
rowIndex
)
{
this
.
rowIndex
=
rowIndex
;
}
public
int
getRowCell
()
{
return
rowCell
;
}
public
void
setRowCell
(
int
rowCell
)
{
this
.
rowCell
=
rowCell
;
public
boolean
isMergerFlag
()
{
boolean
ret
=
mergerFlag
;
mergerFlag
=
false
;
return
ret
;
}
public
int
getRowIndexHistory
()
{
return
rowIndexHistory
;
}
public
void
setRowIndexHistory
(
int
rowIndexHistory
)
{
this
.
rowIndexHistory
=
rowIndexHistory
;
}
public
int
getRowCellHistory
()
{
return
rowCellHistory
;
}
public
void
setRowCellHistory
(
int
rowCellHistory
)
{
this
.
rowCellHistory
=
rowCellHistory
;
}
}
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