基于模版生成word
AutoPoi的主要特点
1.设计精巧,使用简单
2.接口丰富,扩展简单
3.默认值多,write less do more
4.spring mvc支持,web导出可以简单明了
1、引入maven
<dependency>
<groupId>org.jeecgframework</groupId>
<artifactId>autopoi-web</artifactId>
<version>1.4.8</version>
</dependency>
2、word模版编写(模版文件已上传,可在顶部下载)
注意事项
1、序列号{ {.id}},前面是有"."的
2、java代码中的“ lm.put(“$fe:testList”, lm); ”,是专门回来处理第一行的填充值的
目前仅支持表格循环、变量替换
{
{
department}}
{
{
person}}
{
{
image}}
{
{
time}}
序列号 | xx | 名称 | 小学生 |
---|---|---|---|
{ {$fe:testList}}{ {.id}} | { {zijin}} | { {quancheng}} | { {bianma}} |
图片以供模版参考
3、java代码
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.jeecg.common.util.DateUtils;
import org.jeecgframework.poi.word.WordExportUtil;
import org.jeecgframework.poi.word.entity.WordImageEntity;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;