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")));