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
190c4773
Commit
190c4773
authored
May 09, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Excel导出功能
parent
7fb1c7b9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
ExcelDao.java
...d/src/main/java/com/yanzuoguang/cloud/excel/ExcelDao.java
+17
-0
ExcelHttp.java
.../src/main/java/com/yanzuoguang/cloud/excel/ExcelHttp.java
+25
-0
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/excel/ExcelDao.java
0 → 100644
View file @
190c4773
package
com
.
yanzuoguang
.
cloud
.
excel
;
import
com.yanzuoguang.db.impl.DbRow
;
/**
* Excel导出接口
*/
public
interface
ExcelDao
{
/**
* 循环处理每行数据
*
* @param excel excel对象
* @param cond 条件参数
*/
void
export
(
DbRow
excel
,
Object
cond
);
}
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/excel/ExcelHttp.java
View file @
190c4773
...
@@ -4,7 +4,9 @@ package com.yanzuoguang.cloud.excel;
...
@@ -4,7 +4,9 @@ package com.yanzuoguang.cloud.excel;
import
com.yanzuoguang.cloud.helper.HttpFileHelper
;
import
com.yanzuoguang.cloud.helper.HttpFileHelper
;
import
com.yanzuoguang.excel.ExcelConsole
;
import
com.yanzuoguang.excel.ExcelConsole
;
import
com.yanzuoguang.excel.ExcelRow
;
import
com.yanzuoguang.excel.ExcelRow
;
import
com.yanzuoguang.excel.ExportBase
;
import
com.yanzuoguang.excel.ExportData
;
import
com.yanzuoguang.excel.ExportData
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -59,4 +61,27 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
...
@@ -59,4 +61,27 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
HttpFileHelper
.
localToDown
(
this
.
getFileName
(),
downFileName
,
response
);
HttpFileHelper
.
localToDown
(
this
.
getFileName
(),
downFileName
,
response
);
return
this
;
return
this
;
}
}
/**
* 导出数据
*
* @param req 请求对接
* @param response 输出结果
*/
public
static
void
export
(
ExportBase
req
,
HttpServletResponse
response
,
ExcelDao
excelDao
)
{
ExcelHttp
excel
=
new
ExcelHttp
<>(
req
.
getConfig
());
try
{
excel
.
open
();
excelDao
.
export
(
excel
,
req
.
getCond
());
excel
.
save
();
excel
.
down
(
response
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
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