XWPFDocument document = new XWPFDocument();
// 文件输出,页面直接下载
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
//这里URLEncoder.encode可以防止中文乱码
String fileName = URLEncoder.encode(UUIDUtil.getUuid(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".docx");
OutputStream out = response.getOutputStream();
document.write(out);
out.close();
文件导出response方式
最新推荐文章于 2022-11-04 10:51:56 发布