当前位置: 首页 > news >正文

poi-tl

官网地址

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();InputStream pictureIs = new ClassPathResource("/templates/picture/pmp.png").getInputStream();FileOutputStream os = new FileOutputStream("templates/output/template-out.docx")) {List<Cards> cards = new ArrayList<>();cards.add(new Cards().setCardNo(1).setCardName("黑魔导").setDEF(2000).setATK(2500).setCardType("暗"));cards.add(new Cards().setCardNo(2).setCardName("青眼白龙").setDEF(2500).setATK(3000).setCardType("光"));cards.add(new Cards().setCardNo(3).setCardName("火焰剑士").setDEF(1600).setATK(1800).setCardType("炎"));cards.add(new Cards().setCardNo(4).setCardName("磁石战士").setDEF(2500).setATK(3500).setCardType("暗"));LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();Configure config = Configure.builder().bind("cards", policy)	// 	绑定插件.build();XWPFTemplate template = XWPFTemplate.compile(is,config).render(new HashMap<String, Object>(){{put("filename", "录取通知书");put("姓名", "祖安蒙多");put("学院", "地面战斗学院");put("专业名称", "地面炮灰");put("大学名称", "火星殖民大学");put("img", Pictures.ofStream(pictureIs, PictureType.JPEG).size(100, 120).create());put("charone",Charts.ofMultiSeries("三幻神", new String[] { "攻击力", "守备力", "战斗值" }).addSeries("奥西里斯的天空龙", new Integer[] { 3000, 3500, 1200 }).addSeries("欧贝里克的巨神兵", new Integer[] { 4000, 2000, 1100 }).addSeries("拉的翼神", new Integer[] { 6000, 1000, 1400 }).create());put("cards", cards);}});template.writeAndClose(os);}return ResponseEntity.ok().build();}


http://www.mrgr.cn/news/98355.html

相关文章:

  • Spark-SQL核心编程(一)
  • 【JavaEE初阶】多线程重点知识以及常考的面试题-多线程进阶(一)
  • Kubernetes Operator 是什么,以及它们的用途
  • 基于瑞芯微RK3576 国产ARM八核2.2GHz A72 NPU 6T AI——MQTT通信方案
  • #4 我们为什么使用物联网? 以及 物联网的整体结构
  • 优先级队列(堆二叉树)底层的实现:
  • Codeforces Round 1017 (Div. 4)题解
  • 9.thinkphp的请求
  • 【STL】set
  • 【LLM】解锁Agent协作:深入了解谷歌 A2A 协议与 Python 实现
  • 前端工程化之自动化构建
  • 07软件测试需求分析案例-修改用户信息
  • UNITY 屏幕UI自适应
  • 使用SVM对心脏数据是否患病进行分类预测
  • UNet深度学习实战遥感航拍图像语义分割
  • 科研软件分享
  • deepin使用autokey添加微信快捷键一键显隐ctrl+alt+w
  • Linux内核中struct net_protocol的early_demux字段解析
  • HarmonyOS 第2章 Ability的开发,鸿蒙HarmonyOS 应用开发入门
  • 7.thinkphp的路由