InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(TEMPLATE);
XWPFDocument document = new XWPFDocument(is);
List<IBodyElement> elements = document.getBodyElements();
for (int i = 0; i < elements.size(); i++) {
document.removeBodyElement(i);
}
CTBody body = document.getDocument().getBody();
CTSectPr docSp = body.getSectPr();
CTPageSz pageSize = docSp.getPgSz();
CTPageMar margin = docSp.getPgMar();
BigInteger pageWidth = pageSize.getW();
pageWidth = pageWidth.add(BigInteger.ONE);
BigInteger totalMargins = margin.getLeft().add(margin.getRight());
BigInteger contentWidth = pageWidth.subtract(totalMargins);
...
XWPFTable table = document.createTable(totalRows, totalColumns);
从模板开始,我创建了一个 XWPFDocument 并向其中添加了一个表。如何在一个页面上添加多个表格?也就是说,也许,我如何插入分页符?