注:我使用的word 2016功能简介:(1)使用jsoup解析html得到我用来生成word的文本(这个你们可以忽略)(2)生成word.设置页边距.设置页脚(页码),设置页码(文本) 一.解析html Document doc = Jsoup.parseBodyFragment(contents); Element body = doc.body(); Elements es = body.getAllElements(); 二.循环Elements获取我需要的html标签 boolean
最近多了一个需求,需要对word模板内容进行替换,一开始用的是word03版的,替换起来比较简单,主要是range对像替换非常方便,而且可以保留替换前的字体样式. InputStream is = new FileInputStream(srcFath); OutputStream os = new FileOutputStream(tempFile); XWPFDocument doc = new XWPFDocument(is); Range range = doc.getRange();