poi-tl
poi-tl(poi template language)是基于Apache POI的Word模板引擎。纯Java组件,跨平台,代码短小精悍,通过插件机制使其具有高度扩展性。
(主要是)支持DOCX格式的Word模板。
主要处理区域有这么几个模块
开始的jar包导入
com.deepoovepoi-tl1.3.1
这个是实现写入表格的方法
public class table {
public static void testRenderMap(final RowRenderData header, final List tableDatas) throws Exception {
Map datas = new HashMap() {
{
put("solution_compare", new MiniTableRenderData(header, tableDatas, MiniTableRenderData.WIDTH_A4_FULL));
}
};
XWPFTemplate template = XWPFTemplate.compile("src/test/resources/template.docx").render(datas);
//表格的模板
FileOutputStream out = new FileOutputStream("out_template2.docx");
template.write(out); //输出的文件名
out.flush();
out.close();
template.close();
}
接下来是main的测试数据
public static void main(String []args) throws Exception {
RowRenderData header;
List tableDatas;
header = new RowRenderData(Arrays.asList(new TextRenderData("FFFFFF", 10,"Word处理解决方案"),
new TextRenderData("FFFFFF",10, "是否跨平台")), "E6E6E6");
RowRenderData row0 = RowRenderData.build("Poi-tl", "纯Java组件,跨平台" );
RowRenderData row1 = RowRenderData.build("Apache Poi", "