官网地址
Poi-tl Documentationword模板引擎https://deepoove.com/poi-tl
github 地址
https://github.com/Sayi/poi-tl/tree/master
gitcode 加速地址
GitCode - 全球开发者的开源社区,开源代码托管平台GitCode是面向全球开发者的开源社区,包括原创博客,开源代码托管,代码协作,项目管理等。与开发者社区互动,提升您的研发效率和质量。https://gitcode.com/gh_mirrors/po/poi-tl/tree/master
Maven依赖
<dependency><groupId>com.deepoove</groupId><artifactId>poi-tl</artifactId><version>1.12.2</version>
</dependency>
使用场景
官方文档 有很多示例,这里就不展示里
场景一
文字指定填充
代码;
@GetMapping("/simple")public ResponseEntity simpleDemo() throws Exception{try(InputStream is = new ClassPathResource("/templates/template.docx").getInputStream();FileOutputStream os = new FileOutputStream("templates/output/template-out.docx")) {XWPFTemplate template = XWPFTemplate.compile(is).render(new HashMap<String, Object>(){{put("filename", "录取通知书");put("姓名", "祖安蒙多");put("学院", "地面战斗学院");put("专业名称", "地面炮灰");put("大学名称", "火星殖民大学");}});template.writeAndClose(os);}return ResponseEntity.ok().build();}