第一步。创建个map。里面是你要替换的唯一标识和对应的值
HashMap<String, String> map = new HashMap<>();
String filetype = legalInstrument.getFiletype();
map.put("${s1}", "把${s1}替换成指定内容。比如姓名啥的");
第二步。读取word模板。我是放到了resources下的templates下面
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("templates/CA签名模板.docx");
第三步。使用poi操作word
XWPFDocument doc = new XWPFDocument(inputStream);
POIWordUtil.replaceWord(doc, map);
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import cn.hutool.core.util.StrUtil;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.

最低0.47元/天 解锁文章
3557

被折叠的 条评论
为什么被折叠?



