Java Word 的模板引擎 poi-tl

码农软件 · 软件分类 · 模板引擎 · 2019-08-22 18:44:08

软件介绍

Java word的模板引擎,对docx格式的文档增加模板语法,简化样式处理,支持对段落、页眉、页脚、表格等模板替换。

poi-tl是基于apache poi的一套拥有简洁API的跨平台的模板引擎。核心API只需要一行代码:

XWPFTemplate template = XWPFTemplate.compile("~/file.docx").render(datas);

所有的语法结构都是以 {{ 开始,以 }} 结束。

  • {{template}} 普通文本

  • {{@template}} 图片

  • {{#template}} 表格

  • {{*template}} 列表

  • {{+template}} 文档

示例

  1. word中包含模板内容{{title}}

  2. 使用 'XWPFTemplate.compile(file).render(datas)'

  3. 输出到流OutputStream

//一行代码
XWPFTemplate template = XWPFTemplate.compile("~/template.docx").render(new HashMap(){{
        put("title", "Pil-tl 模板引擎");
}});
FileOutputStream out = new FileOutputStream("out_template.docx");
template.write(out);
out.flush();
out.close();
template.close();

本文地址:https://codercto.com/soft/d/12943.html

颠覆暴利

颠覆暴利

曾德超、张志前 / 2015-4-1 / 58

本书从金融人士的视角研究互联网时代的金融创新,全面系统地介绍了我国互联网金融的产生背景及原因,梳理了互联网金融的基本理论,分析了互联网金融的各种业态和运营模式,介绍了互联网企业和金融企业的应对策略。本书还对互联网金融存在的风险和监管进行了研究,对互联网金融未来的发展前景进行了展望。本书是学习研究互联网金融不可多得的一本参考书。一起来看看 《颠覆暴利》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换