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
7c942365
Commit
7c942365
authored
Aug 14, 2023
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Excel自定义数据处理器增加单元格/工作簿对象
parent
128b186b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
ExcelHandlerAdapter.java
.../java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java
+6
-1
ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+5
-5
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java
View file @
7c942365
package
com
.
ruoyi
.
common
.
utils
.
poi
;
package
com
.
ruoyi
.
common
.
utils
.
poi
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Workbook
;
/**
/**
* Excel数据格式处理适配器
* Excel数据格式处理适配器
*
*
...
@@ -12,8 +15,10 @@ public interface ExcelHandlerAdapter
...
@@ -12,8 +15,10 @@ public interface ExcelHandlerAdapter
*
*
* @param value 单元格数据值
* @param value 单元格数据值
* @param args excel注解args参数组
* @param args excel注解args参数组
* @param cell 单元格对象
* @param wb 工作簿对象
*
*
* @return 处理后的值
* @return 处理后的值
*/
*/
Object
format
(
Object
value
,
String
[]
args
);
Object
format
(
Object
value
,
String
[]
args
,
Cell
cell
,
Workbook
wb
);
}
}
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
View file @
7c942365
...
@@ -461,7 +461,7 @@ public class ExcelUtil<T>
...
@@ -461,7 +461,7 @@ public class ExcelUtil<T>
}
}
else
if
(!
attr
.
handler
().
equals
(
ExcelHandlerAdapter
.
class
))
else
if
(!
attr
.
handler
().
equals
(
ExcelHandlerAdapter
.
class
))
{
{
val
=
dataFormatHandlerAdapter
(
val
,
attr
);
val
=
dataFormatHandlerAdapter
(
val
,
attr
,
null
);
}
}
else
if
(
ColumnType
.
IMAGE
==
attr
.
cellType
()
&&
StringUtils
.
isNotEmpty
(
pictures
))
else
if
(
ColumnType
.
IMAGE
==
attr
.
cellType
()
&&
StringUtils
.
isNotEmpty
(
pictures
))
{
{
...
@@ -1052,7 +1052,7 @@ public class ExcelUtil<T>
...
@@ -1052,7 +1052,7 @@ public class ExcelUtil<T>
}
}
else
if
(!
attr
.
handler
().
equals
(
ExcelHandlerAdapter
.
class
))
else
if
(!
attr
.
handler
().
equals
(
ExcelHandlerAdapter
.
class
))
{
{
cell
.
setCellValue
(
dataFormatHandlerAdapter
(
value
,
attr
));
cell
.
setCellValue
(
dataFormatHandlerAdapter
(
value
,
attr
,
cell
));
}
}
else
else
{
{
...
@@ -1265,13 +1265,13 @@ public class ExcelUtil<T>
...
@@ -1265,13 +1265,13 @@ public class ExcelUtil<T>
* @param excel 数据注解
* @param excel 数据注解
* @return
* @return
*/
*/
public
String
dataFormatHandlerAdapter
(
Object
value
,
Excel
excel
)
public
String
dataFormatHandlerAdapter
(
Object
value
,
Excel
excel
,
Cell
cell
)
{
{
try
try
{
{
Object
instance
=
excel
.
handler
().
newInstance
();
Object
instance
=
excel
.
handler
().
newInstance
();
Method
formatMethod
=
excel
.
handler
().
getMethod
(
"format"
,
new
Class
[]
{
Object
.
class
,
String
[].
class
});
Method
formatMethod
=
excel
.
handler
().
getMethod
(
"format"
,
new
Class
[]
{
Object
.
class
,
String
[].
class
,
Cell
.
class
,
Workbook
.
class
});
value
=
formatMethod
.
invoke
(
instance
,
value
,
excel
.
args
());
value
=
formatMethod
.
invoke
(
instance
,
value
,
excel
.
args
()
,
cell
,
this
.
wb
);
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
...
...
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