2
votes

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.

Can it be done with Apache POI ? Thanks!

1
you mean word doc or excel doc?Bhavik Shah

1 Answers

1
votes

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