一、制作.ftl后缀的word模板文件
1、新建一个word文档模板
使用其他文本编辑器编写表达式,如:Editplus
2、将word文档另存为xml并改名为.ftl后缀的文件
另存完之后关闭word文档,将demo.xml的后缀修改为.ftl,然后使用文本编辑器打开demo.ftl文件
3、修改.ftl文件并生成最终的模板文件
① 修改图片的数据内容使用表达式代替
替换之后如下:
② 在数据表格中添加循环标签
二、通过模板文件生成word文档
1、添加pom.xml的依赖
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
2、index.jsp中添加一个Echarts图形报表
var option = {
angleAxis: {
type: 'category',
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
z: 10
},
radiusAxis: {
},
polar: {
},
series: [{
type: 'bar',
data: [1, 2, 3, 4, 3, 5, 1],
coordinateSystem: 'polar