Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-csf
Commits
6c1e6f79
Commit
6c1e6f79
authored
Sep 15, 2026
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保费到期提醒15
parent
7b94e33c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
17 deletions
+10
-17
yd-csf-service/src/main/java/com/yd/csf/service/component/TemplateStyleStrategy.java
+10
-17
No files found.
yd-csf-service/src/main/java/com/yd/csf/service/component/TemplateStyleStrategy.java
View file @
6c1e6f79
package
com
.
yd
.
csf
.
service
.
component
;
import
com.alibaba.excel.metadata.Head
;
import
com.alibaba.excel.metadata.data.WriteCellData
;
import
com.alibaba.excel.write.handler.CellWriteHandler
;
import
com.alibaba.excel.write.handler.SheetWriteHandler
;
import
com.alibaba.excel.write.metadata.holder.WriteSheetHolder
;
import
com.alibaba.excel.write.metadata.holder.WriteTableHolder
;
import
com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder
;
import
com.alibaba.excel.write.handler.context.CellWriteHandlerContext
;
import
com.alibaba.excel.write.handler.context.SheetWriteHandlerContext
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.CellStyle
;
...
...
@@ -17,8 +14,6 @@ import org.apache.poi.ss.usermodel.Sheet;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
java.util.List
;
/**
* 严格复刻 policy报表模版.xlsx 的样式:
* 宋体 11 不加粗、四边细边框、垂直居中;对齐与数字格式按列区分;冻结首行;按模板列宽。
...
...
@@ -34,7 +29,7 @@ public class TemplateStyleStrategy implements SheetWriteHandler, CellWriteHandle
private
static
final
int
NUMBER_LEFT
=
2
;
/** 常规右对齐(模板 13:L/M/S) */
private
static
final
int
GENERAL_RIGHT
=
3
;
/** 日期 yyyy/MM/dd 右对齐(模板 12:N/O/Q;P/R
模板为常规右对齐,但
写入真实日期需日期格式) */
/** 日期 yyyy/MM/dd 右对齐(模板 12:N/O/Q;P/R 写入真实日期需日期格式) */
private
static
final
int
DATE_RIGHT
=
4
;
/** 30 列(A..AD)对应的样式类别 */
...
...
@@ -81,10 +76,9 @@ public class TemplateStyleStrategy implements SheetWriteHandler, CellWriteHandle
private
CellStyle
[]
styles
;
@Override
public
void
afterSheetCreate
(
WriteWorkbookHolder
writeWorkbookHolder
,
WriteSheetHolder
writeSheetHolder
)
{
Sheet
sheet
=
writeSheetHolder
.
getSheet
();
Workbook
workbook
=
sheet
.
getWorkbook
();
public
void
afterSheetCreate
(
SheetWriteHandlerContext
context
)
{
Sheet
sheet
=
context
.
getWriteSheetHolder
().
getSheet
();
Workbook
workbook
=
context
.
getWriteWorkbookHolder
().
getWorkbook
();
initStyles
(
workbook
);
for
(
int
i
=
0
;
i
<
COL_WIDTH
.
length
;
i
++)
{
...
...
@@ -95,14 +89,13 @@ public class TemplateStyleStrategy implements SheetWriteHandler, CellWriteHandle
}
@Override
public
void
afterCellDispose
(
WriteSheetHolder
writeSheetHolder
,
WriteTableHolder
writeTableHolder
,
List
<
WriteCellData
<?>>
cellDataList
,
Cell
cell
,
Head
head
,
Integer
relativeRowIndex
,
Boolean
isHead
)
{
public
void
afterCellDispose
(
CellWriteHandlerContext
context
)
{
Cell
cell
=
context
.
getCell
();
int
col
=
cell
.
getColumnIndex
();
if
(
col
<
0
||
col
>=
STYLE_BY_COL
.
length
||
styles
==
null
)
{
if
(
styles
==
null
||
col
<
0
||
col
>=
STYLE_BY_COL
.
length
)
{
return
;
}
// 表头与数据使用同一套按列样式
cell
.
setCellStyle
(
styles
[
STYLE_BY_COL
[
col
]]);
}
...
...
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