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
850b489b
Commit
850b489b
authored
Feb 28, 2023
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导出Excel边框
parent
6590f3cf
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
301 additions
and
117 deletions
+301
-117
ExcelConsole.java
...-db/src/main/java/com/yanzuoguang/excel/ExcelConsole.java
+111
-86
ExcelDefineCell.java
.../src/main/java/com/yanzuoguang/excel/ExcelDefineCell.java
+89
-0
ExcelDefineRow.java
...b/src/main/java/com/yanzuoguang/excel/ExcelDefineRow.java
+40
-0
ExcelRowDefault.java
.../src/main/java/com/yanzuoguang/excel/ExcelRowDefault.java
+2
-13
ExportColumn.java
...-db/src/main/java/com/yanzuoguang/excel/ExportColumn.java
+33
-18
ExportData.java
...il-db/src/main/java/com/yanzuoguang/excel/ExportData.java
+26
-0
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExcelConsole.java
View file @
850b489b
This diff is collapsed.
Click to expand it.
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExcelDefineCell.java
0 → 100644
View file @
850b489b
package
com
.
yanzuoguang
.
excel
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* 单元格
*
* @author 颜佐光
*/
public
class
ExcelDefineCell
{
/**
* 横合并
*/
@ApiModelProperty
(
notes
=
"横合并"
)
private
short
widthSize
;
/**
* 竖合并
*/
@ApiModelProperty
(
notes
=
"竖合并"
)
private
short
heightSize
;
/**
* 对其
*/
@ApiModelProperty
(
notes
=
"左右对其:0-居中,1-左对其,2-右对齐"
)
private
int
alignment
;
/**
* 对其
*/
@ApiModelProperty
(
notes
=
"上下对其:0-居中,1-上对其,2-下对齐"
)
private
int
verticalAlignment
;
/**
* 文字内容
*/
@ApiModelProperty
(
notes
=
"文字内容"
)
private
String
value
;
/**
* 公式,如:SUM(C2:C3),或者SUM(columnName),columnName=数据列名称,公式优先
*/
@ApiModelProperty
(
notes
=
" 公式,如:SUM(C2:C3),或者SUM(columnName),columnName=数据列名称,公式优先.不能SUM(columnA/columnB)"
)
private
String
formula
;
public
short
getWidthSize
()
{
return
widthSize
;
}
public
void
setWidthSize
(
short
widthSize
)
{
this
.
widthSize
=
widthSize
;
}
public
short
getHeightSize
()
{
return
heightSize
;
}
public
void
setHeightSize
(
short
heightSize
)
{
this
.
heightSize
=
heightSize
;
}
public
int
getAlignment
()
{
return
alignment
;
}
public
void
setAlignment
(
int
alignment
)
{
this
.
alignment
=
alignment
;
}
public
int
getVerticalAlignment
()
{
return
verticalAlignment
;
}
public
void
setVerticalAlignment
(
int
verticalAlignment
)
{
this
.
verticalAlignment
=
verticalAlignment
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getFormula
()
{
return
formula
;
}
public
void
setFormula
(
String
formula
)
{
this
.
formula
=
formula
;
}
}
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExcelDefineRow.java
0 → 100644
View file @
850b489b
package
com
.
yanzuoguang
.
excel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 单元格
*
* @author 颜佐光
*/
public
class
ExcelDefineRow
{
/**
* 高度
*/
@ApiModelProperty
(
notes
=
"高度"
)
private
short
height
;
/**
* 单元格
*/
@ApiModelProperty
(
notes
=
"单元格"
)
private
List
<
ExcelDefineCell
>
cells
=
new
ArrayList
<>();
public
short
getHeight
()
{
return
height
;
}
public
void
setHeight
(
short
height
)
{
this
.
height
=
height
;
}
public
List
<
ExcelDefineCell
>
getCells
()
{
return
cells
;
}
public
void
setCells
(
List
<
ExcelDefineCell
>
cells
)
{
this
.
cells
=
cells
;
}
}
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExcelRowDefault.java
View file @
850b489b
...
...
@@ -7,7 +7,7 @@ import com.yanzuoguang.util.base.ObjectHelper;
* 行数据默认处理
* @author 颜佐光
*/
public
class
ExcelRowDefault
implements
ExcelRow
<
Object
>
{
public
class
ExcelRowDefault
<
T
>
implements
ExcelRow
<
T
>
{
/**
* 获取行里面的某列数据
...
...
@@ -17,18 +17,7 @@ public class ExcelRowDefault implements ExcelRow<Object> {
* @return
*/
@Override
public
String
get
(
Object
row
,
String
field
)
{
public
String
get
(
T
row
,
String
field
)
{
return
ObjectHelper
.
getString
(
row
,
field
);
}
private
static
final
ExcelRowDefault
my
=
new
ExcelRowDefault
();
/**
* 获取默认实例
*
* @return
*/
public
static
ExcelRowDefault
getInstance
()
{
return
my
;
}
}
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExportColumn.java
View file @
850b489b
...
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.excel;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.apache.poi.ss.usermodel.CellStyle
;
/**
* 列设置
...
...
@@ -18,7 +19,7 @@ public class ExportColumn {
private
String
title
;
/**
* 数据
单元格
* 数据
列名称
*/
@ApiModelProperty
(
notes
=
"数据列名称"
)
private
String
name
;
...
...
@@ -28,18 +29,25 @@ public class ExportColumn {
*/
@ApiModelProperty
(
notes
=
"数据是否合并"
)
private
boolean
merger
;
/**
* 合并組
*/
@ApiModelProperty
(
notes
=
"合并組"
)
private
String
megerGroup
;
/**
* 宽度
*/
@ApiModelProperty
(
notes
=
"宽度"
)
private
short
width
;
/**
* 对其
*/
@ApiModelProperty
(
notes
=
"左右对其:0-居中,1-左对其,2-右对齐"
)
private
int
alignment
;
/**
* 对其
*/
@ApiModelProperty
(
notes
=
"上下对其:0-居中,1-上对其,2-下对齐"
)
private
int
verticalAlignment
;
ExcelMergerData
groupData
=
new
ExcelMergerData
();
CellStyle
cellStyle
;
public
ExportColumn
()
{
}
...
...
@@ -55,11 +63,10 @@ public class ExportColumn {
this
.
width
=
width
;
}
public
ExportColumn
(
String
title
,
String
name
,
boolean
merger
,
String
megerGroup
,
short
width
)
{
public
ExportColumn
(
String
title
,
String
name
,
boolean
merger
,
short
width
)
{
this
.
title
=
title
;
this
.
name
=
name
;
this
.
merger
=
merger
;
this
.
megerGroup
=
megerGroup
;
this
.
width
=
width
;
}
...
...
@@ -87,14 +94,6 @@ public class ExportColumn {
this
.
merger
=
merger
;
}
public
String
getMegerGroup
()
{
return
megerGroup
;
}
public
void
setMegerGroup
(
String
megerGroup
)
{
this
.
megerGroup
=
megerGroup
;
}
public
short
getWidth
()
{
if
(
this
.
width
<
1
)
{
return
ExportData
.
COLUMN_WIDTH
;
...
...
@@ -105,4 +104,20 @@ public class ExportColumn {
public
void
setWidth
(
short
width
)
{
this
.
width
=
width
;
}
public
int
getAlignment
()
{
return
alignment
;
}
public
void
setAlignment
(
int
alignment
)
{
this
.
alignment
=
alignment
;
}
public
int
getVerticalAlignment
()
{
return
verticalAlignment
;
}
public
void
setVerticalAlignment
(
int
verticalAlignment
)
{
this
.
verticalAlignment
=
verticalAlignment
;
}
}
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExportData.java
View file @
850b489b
...
...
@@ -97,11 +97,21 @@ public class ExportData {
@ApiModelProperty
(
notes
=
"自动换行"
)
private
boolean
line
;
/**
* 数据开始自定义行
*/
@ApiModelProperty
(
notes
=
"数据开始自定义行"
)
private
List
<
ExcelDefineRow
>
startRows
=
new
ArrayList
<>();
/**
* 包含列
*/
@ApiModelProperty
(
notes
=
"包含列"
)
private
List
<
ExportColumn
>
columns
=
new
ArrayList
<>();
/**
* 数据结束自定义行
*/
@ApiModelProperty
(
notes
=
"数据结束自定义行"
)
private
List
<
ExcelDefineRow
>
endRows
=
new
ArrayList
<>();
public
String
getServerPath
()
{
return
serverPath
;
...
...
@@ -195,6 +205,14 @@ public class ExportData {
this
.
line
=
line
;
}
public
List
<
ExcelDefineRow
>
getStartRows
()
{
return
startRows
;
}
public
void
setStartRows
(
List
<
ExcelDefineRow
>
startRows
)
{
this
.
startRows
=
startRows
;
}
public
List
<
ExportColumn
>
getColumns
()
{
return
columns
;
}
...
...
@@ -202,4 +220,12 @@ public class ExportData {
public
void
setColumns
(
List
<
ExportColumn
>
columns
)
{
this
.
columns
=
columns
;
}
public
List
<
ExcelDefineRow
>
getEndRows
()
{
return
endRows
;
}
public
void
setEndRows
(
List
<
ExcelDefineRow
>
endRows
)
{
this
.
endRows
=
endRows
;
}
}
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