From 808fe2c4e605801c7056c03f5fb5a0a8f6ea0f16 Mon Sep 17 00:00:00 2001 From: jipengfei-jpf <1558143046@qq.com> Date: Mon, 20 May 2019 22:29:18 +0800 Subject: [PATCH] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改案例 --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 728fb233..59749e57 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,9 @@ public class Down { @GetMapping("/a.htm") public void cooperation(HttpServletRequest request, HttpServletResponse response) { ServletOutputStream out = response.getOutputStream(); + response.setContentType("multipart/form-data"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx"); ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX, true); String fileName = new String(("UserInfo " + new SimpleDateFormat("yyyy-MM-dd").format(new Date())) .getBytes(), "UTF-8"); @@ -134,9 +137,7 @@ public class Down { sheet1.setSheetName("第一个sheet"); writer.write0(getListString(), sheet1); writer.finish(); - response.setContentType("multipart/form-data"); - response.setCharacterEncoding("utf-8"); - response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx"); + out.flush(); } }