<!-- 模版引擎用到的jar包 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.3</version>
</dependency>
![]()
1 /**
2 *
3 * @throws Exception
4 * @Description 模板導出
5 * @category
6 * @author 张银彪
7 * @date 2020年2月19日 下午4:13:46
8 */
9 @GetMapping("/test")
10 public void name() throws Exception {
11 XWPFTemplate template = XWPFTemplate.compile(ResourceUtils.getFile("classpath:售后服务表单2.docx").getAbsolutePath()).render(new HashMap<String, Object>(){{
12 put("title", "Poi-tl 模板引擎");
13 }});
14 FileOutputStream out = new FileOutputStream("out_template.docx");
15 template.write(out);
16 out.flush();
17 out.close();
18 template.close();
19 }
View Code