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
b0c53197
Commit
b0c53197
authored
May 09, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Excel导出功能
parent
00cec6ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
ExcelDao.java
...d/src/main/java/com/yanzuoguang/cloud/excel/ExcelDao.java
+3
-2
ExcelHttp.java
.../src/main/java/com/yanzuoguang/cloud/excel/ExcelHttp.java
+8
-8
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/excel/ExcelDao.java
View file @
b0c53197
...
...
@@ -4,9 +4,10 @@ import com.yanzuoguang.db.impl.DbRow;
/**
* Excel导出接口
*
* @author 颜佐光
*/
public
interface
ExcelDao
{
public
interface
ExcelDao
<
T
extends
Object
,
M
extends
Object
>
{
/**
* 循环处理每行数据
...
...
@@ -14,5 +15,5 @@ public interface ExcelDao {
* @param excel excel对象
* @param cond 条件参数
*/
void
export
(
DbRow
excel
,
Object
cond
);
void
export
(
DbRow
<
M
>
excel
,
T
cond
);
}
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/excel/ExcelHttp.java
View file @
b0c53197
...
...
@@ -55,31 +55,31 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
* @param downFileName 下载文件名
*/
public
ExcelHttp
down
(
HttpServletResponse
response
,
String
downFileName
)
throws
IOException
{
if
(
StringHelper
.
isEmpty
(
downFileName
))
{
if
(
StringHelper
.
isEmpty
(
downFileName
))
{
downFileName
=
this
.
getConfig
().
getFileName
();
}
HttpFileHelper
.
localToDown
(
this
.
getFileName
(),
downFileName
,
response
);
HttpFileHelper
.
localToDown
(
this
.
getFileName
(),
downFileName
,
response
);
return
this
;
}
/**
* 导出数据
*
* @param req 请求对接
* @param req
请求对接
* @param response 输出结果
*/
public
static
void
export
(
ExportBase
req
,
HttpServletResponse
response
,
ExcelDao
excelDao
)
{
ExcelHttp
excel
=
new
ExcelHttp
<>(
req
.
getConfig
());
public
static
<
T
extends
Object
,
M
extends
Object
>
void
export
(
ExportBase
<
T
>
req
,
HttpServletResponse
response
,
ExcelDao
<
T
,
M
>
excelDao
)
{
ExcelHttp
<
M
>
excel
=
new
ExcelHttp
<>(
req
.
getConfig
());
try
{
excel
.
open
();
excelDao
.
export
(
excel
,
req
.
getCond
());
excel
.
save
();
excel
.
down
(
response
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
CodeException
(
"下载失败"
,
e
);
}
finally
{
throw
new
CodeException
(
"下载失败"
,
e
);
}
finally
{
// 删除生成的临时文件
excel
.
remove
();
}
...
...
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