<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.4.0</version>
</dependency>
@PostMapping("export2")
public void export(HttpServletRequest request, HttpServletResponse response) {
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd");
Map<String, Object> params = new HashMap<>();
params.put("title","这是标题");
params.put("name","李四");
try {
XWPFDocument doc = WordExportUtil.exportWord07("D:\\export.docx", params);
String filename = "d:/test/"+22+".docx";
FileOutputStream fos = new FileOutputStream(filename);
doc.write(fos);
// 设置强制下载不打开
response.setContentType("application/force-download");
// 设置文件名
response.addHeader("Content-Disposition", "attachment;fileName="+filename);
OutputStream out = response.getOutputStream();
doc.write(out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}finally {
// delAllFile("E:/test/");
}
}