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://www.codercto.com/soft/d/12943.html

企业应用架构模式

企业应用架构模式

Martin Fowler / 人民邮电出版社 / 2009 / 79.00元

随着信息技术的广泛应用,系统需要处理的数据量越来越大,企业级软件开发已经渐成主流,而开发人员面临的困难与挑战也是显而易见的。更糟糕的是,这一领域的资料一直非常缺乏。 本书是软件开发大师Martin Fowler的代表作,采用模式的形式系统总结了业界多年积累的经验,被称为“企业级应用开发领域的圣经”,出版以来一直畅销不衰,至今仍然无可替代。作 者在精彩地阐述了企业应用开发和设计中的核心原则基础......一起来看看 《企业应用架构模式》 这本书的介绍吧!

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

在线压缩/解压 JS 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器