|
@@ -26,6 +26,7 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
@@ -564,31 +565,15 @@ public class ManageServiceImpl implements ManageService {
|
|
|
cell.setCellValue(m.getGmtModified().toString());
|
|
|
}
|
|
|
}
|
|
|
- //生成excel文件
|
|
|
-
|
|
|
- buildExcelFile("经营数据管理平台数据统计表_" + TimeUtil.getPreDateStr() + ".xls", workbook);
|
|
|
-
|
|
|
- //浏览器下载excel
|
|
|
- buildExcelDocument("经营数据管理平台数据统计表_" + TimeUtil.getPreDateStr() + ".xls",workbook, response);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //生成excel文件
|
|
|
- protected void buildExcelFile(String filename,HSSFWorkbook workbook) throws Exception{
|
|
|
- FileOutputStream fos = new FileOutputStream(filename);
|
|
|
- workbook.write(fos);
|
|
|
- fos.flush();
|
|
|
- fos.close();
|
|
|
- }
|
|
|
-
|
|
|
- //浏览器下载excel
|
|
|
- protected void buildExcelDocument(String filename,HSSFWorkbook workbook,HttpServletResponse response) throws Exception{
|
|
|
- response.setContentType("application/vnd.ms-excel");
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(filename, "utf-8"));
|
|
|
- OutputStream outputStream = response.getOutputStream();
|
|
|
- workbook.write(outputStream);
|
|
|
- outputStream.flush();
|
|
|
- outputStream.close();
|
|
|
+ //清空response
|
|
|
+ response.reset();
|
|
|
+ //设置response的Header
|
|
|
+ String fileName = "经营数据管理平台数据统计表_" + TimeUtil.getPreDateStr() + ".xls";
|
|
|
+ response.reset();
|
|
|
+ response.setContentType("contentType=application/vnd.ms-excel");
|
|
|
+ response.setHeader("Content-disposition","attachment;filename="+URLEncoder.encode(fileName,"utf-8"));
|
|
|
+ workbook.write(response.getOutputStream());
|
|
|
+ response.flushBuffer();
|
|
|
}
|
|
|
|
|
|
private void createTitle(HSSFWorkbook workbook, HSSFSheet sheet, ManageTypeEnum type) {
|