2020-01-16 14:46
public void write(HttpServletResponse rsp, String file) {
OutputStream out = null;
try {
String fileName = URLEncoder.encode(file, "utf-8");
rsp.reset();
rsp.setHeader("Content-disposition", "attachment; filename=" + fileName);
rsp.setContentType("application/msexcel;charset=UTF-8");
out = rsp.getOutputStream();
workBook.write(out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}