Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
6efceac4
提交
6efceac4
authored
12月 03, 2024
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Excel注解支持wrapText是否允许内容换行
上级
77a63504
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
9 行增加
和
3 行删除
+9
-3
Excel.java
...mmon/src/main/java/com/ruoyi/common/annotation/Excel.java
+5
-0
ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+4
-3
没有找到文件。
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
浏览文件 @
6efceac4
...
...
@@ -83,6 +83,11 @@ public @interface Excel
*/
public
String
prompt
()
default
""
;
/**
* 是否允许内容换行
*/
public
boolean
wrapText
()
default
false
;
/**
* 设置只能选择不能输入的列内容.
*/
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
浏览文件 @
6efceac4
...
...
@@ -950,7 +950,7 @@ public class ExcelUtil<T>
*/
public
void
annotationDataStyles
(
Map
<
String
,
CellStyle
>
styles
,
Field
field
,
Excel
excel
)
{
String
key
=
StringUtils
.
format
(
"data_{}_{}_{}_{}
"
,
excel
.
align
(),
excel
.
color
(),
excel
.
backgroundColor
(),
excel
.
cellType
());
String
key
=
StringUtils
.
format
(
"data_{}_{}_{}_{}
_{}"
,
excel
.
align
(),
excel
.
color
(),
excel
.
backgroundColor
(),
excel
.
cellType
(),
excel
.
wrapText
());
if
(!
styles
.
containsKey
(
key
))
{
CellStyle
style
=
wb
.
createCellStyle
();
...
...
@@ -966,6 +966,7 @@ public class ExcelUtil<T>
style
.
setBottomBorderColor
(
IndexedColors
.
GREY_50_PERCENT
.
getIndex
());
style
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
style
.
setFillForegroundColor
(
excel
.
backgroundColor
().
getIndex
());
style
.
setWrapText
(
excel
.
wrapText
());
Font
dataFont
=
wb
.
createFont
();
dataFont
.
setFontName
(
"Arial"
);
dataFont
.
setFontHeightInPoints
((
short
)
10
);
...
...
@@ -994,7 +995,7 @@ public class ExcelUtil<T>
if
(
isSubList
())
{
// 填充默认样式,防止合并单元格样式失效
sheet
.
setDefaultColumnStyle
(
column
,
styles
.
get
(
StringUtils
.
format
(
"data_{}_{}_{}_{}
"
,
attr
.
align
(),
attr
.
color
(),
attr
.
backgroundColor
(),
attr
.
cellType
())));
sheet
.
setDefaultColumnStyle
(
column
,
styles
.
get
(
StringUtils
.
format
(
"data_{}_{}_{}_{}
_{}"
,
attr
.
align
(),
attr
.
color
(),
attr
.
backgroundColor
(),
attr
.
cellType
(),
attr
.
wrapText
())));
if
(
attr
.
needMerge
())
{
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
rownum
-
1
,
rownum
,
column
,
column
));
...
...
@@ -1137,7 +1138,7 @@ public class ExcelUtil<T>
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
subMergedFirstRowNum
,
subMergedLastRowNum
,
column
,
column
));
}
}
cell
.
setCellStyle
(
styles
.
get
(
StringUtils
.
format
(
"data_{}_{}_{}_{}
"
,
attr
.
align
(),
attr
.
color
(),
attr
.
backgroundColor
(),
attr
.
cellType
())));
cell
.
setCellStyle
(
styles
.
get
(
StringUtils
.
format
(
"data_{}_{}_{}_{}
_{}"
,
attr
.
align
(),
attr
.
color
(),
attr
.
backgroundColor
(),
attr
.
cellType
(),
attr
.
wrapText
())));
// 用于读取对象中的属性
Object
value
=
getTargetValue
(
vo
,
field
,
attr
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论