Browse Source

Update README.md

修改案例
developing
jipengfei-jpf 6 years ago committed by GitHub
parent
commit
808fe2c4e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      README.md

7
README.md

@ -127,6 +127,9 @@ public class Down {
@GetMapping("/a.htm") @GetMapping("/a.htm")
public void cooperation(HttpServletRequest request, HttpServletResponse response) { public void cooperation(HttpServletRequest request, HttpServletResponse response) {
ServletOutputStream out = response.getOutputStream(); 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); ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX, true);
String fileName = new String(("UserInfo " + new SimpleDateFormat("yyyy-MM-dd").format(new Date())) String fileName = new String(("UserInfo " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
.getBytes(), "UTF-8"); .getBytes(), "UTF-8");
@ -134,9 +137,7 @@ public class Down {
sheet1.setSheetName("第一个sheet"); sheet1.setSheetName("第一个sheet");
writer.write0(getListString(), sheet1); writer.write0(getListString(), sheet1);
writer.finish(); writer.finish();
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx");
out.flush(); out.flush();
} }
} }

Loading…
Cancel
Save