1.模板

username:${username}
password:${password}
<#list mylist as item>
${item.name!}
${item.password!}
${item.sex!}
${item.phto!}
</#list >

2.Java类

package servlet;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import org.junit.Test; import bean.TestFreemarkerBean;
import freemarker.template.Configuration;
import freemarker.template.Template; public class FreeMarkerExportWord { @Test
public void exportSimpleWord() throws Exception {
// 要填充的数据, 注意map的key要和word中${xxx}的xxx一致
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("username", "张三");
dataMap.put("password", "男"); // Configuration用于读取ftl文件
Configuration configuration = new Configuration();
configuration.setDefaultEncoding("utf-8"); /*
* 以下是两种指定ftl文件所在目录路径的方式, 注意这两种方式都是 指定ftl文件所在目录的路径,而不是ftl文件的路径
*/
// 指定路径的第一种方式(根据某个类的相对路径指定)
configuration.setClassForTemplateLoading(this.getClass(), "");
// 指定路径的第二种方式,我的路径是C:/a.ftl
// configuration.setDirectoryForTemplateLoading(new File("C:/")); List<TestFreemarkerBean> list = new ArrayList<>();
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
list.add(new TestFreemarkerBean("乔治", "123456", "男", "wwwwwwww"));
dataMap.put("mylist", list);
// 输出文档路径及名称
File outFile = new File("F:/test.doc"); // 以utf-8的编码读取ftl文件
Template t = configuration.getTemplate("test2.ftl", "utf-8");
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8"), 10240);
t.process(dataMap, out);
out.close();
}
}

3.测试:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQEAAAFwCAIAAAA38FnOAAAYI0lEQVR4nO2dwZmjvBJFlQIxKAVyUAiKgQT+hVazJQMyIIGnCEhACZCBcuAt7teaGoGx3T2Inq57VmOwsdxTB0oClcxGiG7M3Q0g5GboANEOHSDaoQNEO3SAaIcOEO3QAaIdOkC0QweIdugA0Q4dINqhA0Q7dIBohw4Q7dABoh06QLRDB4h2rnLAGNpF/g3oANEOHSDaoQNEO3SgNeu6ln8755ZlubExZKMDDYgxjoK+78dxxC5jjFRi27ac8+e+ZRzHGONX26oSOnA5OedH5/7qr7QsS9/3lQbTNI3PCCEYY7quSyk1+EU/DDrQmkcO5Jy7rvPeV1eG6iX569CB1hw6kHPu+36e5/vapRc60ALvfclbrLWVAzlndo5vhA785utR2Pd913X7fq0M8RBCSW/QJx6GgQnPjVwVqf/9958xxjn3+5uMMcbIOIsx9n2P7d77EII8QtlrrS0DKdu2jePovcfZNOc8DAPes67ruq4hBGtt2d51nUwwcs54A750GAbE67IsaC06l977lJK1tus6OdjyqEmFVxyQGGOmaao2vqtizpkjQl/hwuvAOI7SgZyzdGBd15IV4Fwo3xxj7Lqu7JXjicgocCjv/bIsKSVjTEoJx0EQ47MxRjn+6L0vnU5kIMMwlMPiG9HOEAKE8d4/bdJTuq6Tf4cy1IO/ksR7b4ypOgbnQ0PQ8rwv8evXrxebqpB2DmBjcWBZlmqvfGmtlee2lJIMIxxqP4SyfZzR5ZlYfmkIQcaKbKH8d/mI3Pi0SY+Ah2UQs5i2fWSM+0tBxbqun75vAOjACbc5gJGQEEKMEf/BJaBxXt8fUCYJj858cODkg3hPSahedOCVJj0i51yaWpmPY8YYrxgRknFPB064zYHtIytADl1S8+0jjvdUDhzG37kDy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oQNEO3SAaIcOEO3QAaIdOkC0QweIdugA0U4LB9Z1PayPEmNEAWpjTFVDDiVVuq5D/bmTx0tRbEtuwack1dydcRwxi/+ksgvRw7UOhBAQ5ftH/zGrBiG4rmvf97KEhKwxgck0h8EaY8TkMrkRzkjkBANUfodvIYSu6/7ezyX/JNc6gDUHvPd7B6oS6tXMyWo2fd/3+ytJztla23Vd5UBVzU6Cef1FCdR9ef9nkR9Fu3lk9RcbU4W1dMB7Lx0odRclIYQQwn4y2snctH29R0Juc2Ce52r1gGr2sKTv++rNKSXkTm85UF1eCNludKAixni4NAH60/tEqEw1rhzA7E3UYER/unQkUOQLb9jvJWr5Lg4cDtE45xCpVTXScRzLUM/eAbl8E3q9+DgcwDgSyvRi6In1epXzLRwYhuHRqko5Z6wwUHKYaqS1cmBd1yrbsdbiDcWBam81clqgA0q434ETAeQRSqZUrVrwtFhdWf615EJyL3rV5SVrlSrkZgdeEWD7CF8kS+YBpXzvPnE6cUC2jfV6dXKnA1hJSW5BgGLpMRmsh+ELquuA97667eW9L/nP/p4xlnXaWK9XMXeOjVajPSklKIGIl3pg4b3Dg1cOOOeqw8qFP4ZhqEafrLVlL0NfJ5c7gAVVq4WY1nXFfWJJeS4IK9aUZyVijNUCNvLg1loZ9HgGCVkTRn7kjWEs+j0MA8aF8CiH7F3QAYVc6wAGNyXYjjP9HhmsWH8AY6OHN7aqg5dM6eRRvG3bUkrlyJDhyj8A+Qfgs9NEO3SAaIcOEO3QAaIdOkC0QweIdugA0Q4dINqhA0Q7dIBohw4Q7fwf39a+i5nrE0MAAAAASUVORK5CYII=" alt="" />

Freemarker导出word的简单使用的更多相关文章

  1. 使用Freemarker导出Word文档(包含图片)代码实现及总结

    .personSunflowerP { background: rgba(51, 153, 0, 0.66); border-bottom: 1px solid rgba(0, 102, 0, 1); ...

  2. freemarker导出word带图片

    导出word带图片 如果你需要在word中添加图片,那你就在第一步制作模板时,加入一张图片占位,然后打开xml文档,可以看到如下的一片base64编码后的代码: <w:binData w:nam ...

  3. freemarker导出word文档——WordXML格式解析

    前不久,公司一个项目需要实现导出文档的功能,之前是一个同事在做,做了3个星期,终于完成了,但是在项目上线之后却发现导出的文档有问题,此时,这个同事已经离职,我自然成为接班者,要把导出功能实现,但是我看 ...

  4. freemarker导出word文档

    使用freemarker导出word文档的过程 **************************************************************************** ...

  5. freemarker导出word档

    1.word另存为xml:2.xml文件后缀名改成ftl:3.编写完整json字符串备用:4.修改ftl中动态字段为json中对应字段名:5.编写java代码自动生成word文件:(注意:换行用< ...

  6. freemarker导出word的一些问题

    首先,了解下freemarker导出word的流程: 参考https://www.cnblogs.com/llfy/p/9303208.html 异常一: freemarker.core.ParseE ...

  7. 关于使用freemarker导出word

    java使用FreeMarker导出word 一.      先做一个word模板 二.      将该word文件另存为xml格式(注意是另存为,不是直接改扩展名) 三.     打开xml文件把要 ...

  8. java freemarker导出word时添加或勾选复选框

    最近项目导出word碰到一个需求,要求根据数据动态的决定word里的复选框是否勾选, 公司导出word用的是freemarker,相比较其他技术,freemarker可以很容易的控制输出样式, 在wo ...

  9. Java用freemarker导出word

    概述 最近一个项目要导出word文档,折腾老半天,发现还是用freemarker的模板来搞比较方便省事,现总结一下关键步骤,供大家参考,这里是一个简单的试卷生成例子. 详细 代码下载:http://w ...

随机推荐

  1. JSP 和 Servlet 的工作原理和生命周期

    JSP的英文名叫Java Server Pages,翻译为中文是Java服务器页面的意思,其底层就是一个简化的Servlet设计,是由sum公司主导参与建立的一种动态网页技术标准.Servlet 就是 ...

  2. WordPress 之 在注册界面 实现 注册后密码直接显示在页面上

    前言:WordPress 功能无疑强大的,但有些功能实现上还是有少许不尽人意,比如在 网站上有新用户注册后,必须下发到用户填写的邮件才能接收到新密码,而密码又是系统自动生成的,如果因为某些原因用户接收 ...

  3. MT【12】三点坐标求面积

    $L_1,L_2$是O发出的两条射线,C是一个常数,一条动直线$l$分别与$L_1,L_2$交于A,B两点.$S_{\Delta ABC}=C$,求A,B的中点D的轨迹方程.(2012北大自主招生) ...

  4. Leetcode 125.验证回文串 By Python

    思路 显然一个字符串不止包括字母和数字字符,所以我们可以先提取出来我们要进行比较的字符 还有一个问题是,字母是分大小写的,我们要统一大写或者统一小写,就是规范化 代码 class Solution(o ...

  5. BZOJ 4671 异或图 | 线性基 容斥 DFS

    题面 Description 定义两个结点数相同的图 G1 与图 G2 的异或为一个新的图 G, 其中如果 (u, v) 在 G1 与 G2 中的出现次数之和为 1, 那么边 (u, v) 在 G 中 ...

  6. 洛谷 P4097 [HEOI2013]Segment 解题报告

    P4097 [HEOI2013]Segment 题目描述 要求在平面直角坐标系下维护两个操作: 在平面上加入一条线段.记第 \(i\) 条被插入的线段的标号为 \(i\) 给定一个数 \(k\),询问 ...

  7. pyEcharts

    例子: from pyecharts import Line line = Line("我的第一个图表", "这里是副标题",width="800px ...

  8. 设计模式 (二)——观察者模式(Observer,行为型)

    1.概述 使用设计模式可以提高代码的可复用性.可扩充性和可维护性.观察者模式(Observer Pattern)属于行为型模式,在对象之间定义一对多的依赖,这样一来,当一个对象改变状态,依赖它的对象都 ...

  9. Java -- JDBC_利用反射及 JDBC 元数据编写通用的查询方法

    先利用 SQL 进行查询,得到结果集: 利用反射创建实体类的对象:创建对象: 获取结果集的列的别名: 再获取结果集的每一列的值, 结合 3 得到一个 Map,键:列的别名,值:列的值: 再利用反射为 ...

  10. 常用数据结构及算法C#/Java实现

    常用数据结构及算法C#实现 1.冒泡排序.选择排序.插入排序(三种简单非递归排序) ,, , , , , , , , , }; //冒泡排序 int length = waitSort.Length; ...