Apache POI - Word (docx) 文档中的多列 [英] Apache POI - multiple columns in a Word (docx) document

查看:51
本文介绍了Apache POI - Word (docx) 文档中的多列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个包含多列的 Word 文档.这样做的原因(而不是使用表格)是数据将跨越多个页面,并且只有在添加到新页面之前我可以填充整个页面的列.

I'm trying to create a word document with multiple columns. The reason for doing this (rather than using tables) is that the data will span multiple pages and only with columns I can fill the whole page before adding to a new one.

可以用 Apache POI 来完成吗?谢谢!

Can it be done with Apache POI ? Thanks!

推荐答案

如何使用以前创建的多列空文档?像这样:

How about using previously created empty document with multiple columns? Like this:

    XWPFDocument document = new XWPFDocument(PoiTest.class.getResourceAsStream("twocolumn.docx"));
    XWPFParagraph tmpParagraph = document.getParagraphs().get(0);

    for (int i = 0; i < 100; i++) {
        XWPFRun tmpRun = tmpParagraph.createRun();
        tmpRun.setText("LALALALAALALAAAA");
        tmpRun.setFontSize(18);
    }
    document.write(new FileOutputStream(new File("C:\\temp\\poi.docx")));

这篇关于Apache POI - Word (docx) 文档中的多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆