From 9f4e458f031ee3da14a5b45e11321a096829bfe7 Mon Sep 17 00:00:00 2001 From: zhuzhe Date: Thu, 10 Oct 2019 15:10:24 +0800 Subject: [PATCH] =?UTF-8?q?excel=20=E5=AF=BC=E5=87=BA=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/space/utils/excel/ExcelUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/space/utils/excel/ExcelUtils.java b/src/main/java/com/space/utils/excel/ExcelUtils.java index 8500850..df20026 100644 --- a/src/main/java/com/space/utils/excel/ExcelUtils.java +++ b/src/main/java/com/space/utils/excel/ExcelUtils.java @@ -180,7 +180,9 @@ public static void exportExcel(String file) throws Exception { * @param resp * @throws Exception */ - public static void export(HttpServletResponse resp) throws Exception { + public static void export(HttpServletResponse resp, String filename) throws Exception { + resp.setHeader("Content-disposition", "attachment; filename=" + filename + ".xlsx"); + resp.setContentType("application/msexcel"); OutputStream fileOut = resp.getOutputStream(); wb.write(fileOut); fileOut.close();