Commit d4223df4 authored by yanzg's avatar yanzg

下载视频

parent 61f8d6b7
...@@ -109,8 +109,8 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -109,8 +109,8 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
* @param response 输出结果 * @param response 输出结果
* @param excelDao dao层实现接口 * @param excelDao dao层实现接口
*/ */
public static <T extends Object, M extends Object> void export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao) { public static <T extends Object, M extends Object> ExcelHttp<M> export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao) {
export(req, response, excelDao, null); return export(req, response, excelDao, null);
} }
/** /**
...@@ -121,7 +121,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -121,7 +121,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
* @param excelDao dao层实现接口 * @param excelDao dao层实现接口
* @param excelStatus excel状态实现 * @param excelStatus excel状态实现
*/ */
public static <T extends Object, M extends Object> void export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao, ExcelStatus<M> excelStatus) { public static <T extends Object, M extends Object> ExcelHttp<M> export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao, ExcelStatus<M> excelStatus) {
ExcelHttp<M> excel = export(req, excelDao, excelStatus); ExcelHttp<M> excel = export(req, excelDao, excelStatus);
try { try {
// 等待下载模式,下载文件 // 等待下载模式,下载文件
...@@ -133,6 +133,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -133,6 +133,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
// 删除生成的临时文件 // 删除生成的临时文件
excel.remove(); excel.remove();
} }
return excel;
} }
private static <T, M> void releaseExcel(ExportBase<T> req, ExcelDao<T, M> excelDao, ExcelHttp<M> excel) { private static <T, M> void releaseExcel(ExportBase<T> req, ExcelDao<T, M> excelDao, ExcelHttp<M> excel) {
......
...@@ -186,6 +186,9 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -186,6 +186,9 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
* 初始化Excel对象 * 初始化Excel对象
*/ */
protected void initExcel(TableHead head) { protected void initExcel(TableHead head) {
if (this.excelStatus != null) {
excelStatus.excelInit(this);
}
if (this.workbook != null) { if (this.workbook != null) {
throw YzgError.getRuntimeException("034"); throw YzgError.getRuntimeException("034");
} }
...@@ -389,7 +392,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -389,7 +392,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
*/ */
public ExcelConsole save() { public ExcelConsole save() {
if (this.excelStatus != null) { if (this.excelStatus != null) {
excelStatus.excelFinish(); excelStatus.excelFinish(this);
} }
if (workbook == null) { if (workbook == null) {
return this; return this;
......
...@@ -7,6 +7,13 @@ package com.yanzuoguang.excel; ...@@ -7,6 +7,13 @@ package com.yanzuoguang.excel;
*/ */
public interface ExcelStatus<T extends Object> { public interface ExcelStatus<T extends Object> {
/**
* Excel处理
*
* @param excel
*/
void excelInit(ExcelConsole<T> excel);
/** /**
* 循环处理每行数据 * 循环处理每行数据
* *
...@@ -17,5 +24,5 @@ public interface ExcelStatus<T extends Object> { ...@@ -17,5 +24,5 @@ public interface ExcelStatus<T extends Object> {
/** /**
* 处理Excel结束 * 处理Excel结束
*/ */
void excelFinish(); void excelFinish(ExcelConsole<T> excel);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment