How can I create a simple docx file with Apache POI?

前端 未结 2 1647
挽巷
挽巷 2020-12-28 14:09

I\'m searching for a simple example code or a complete tutorial how to create a docx file with Apache POI and its underlying openxml4j.

I t

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 14:49

    Here is how you can create a simple docx file with POI :

    XWPFDocument document = new XWPFDocument();
    XWPFParagraph tmpParagraph = document.createParagraph();
    XWPFRun tmpRun = tmpParagraph.createRun();
    tmpRun.setText("LALALALAALALAAAA");
    tmpRun.setFontSize(18);
    document.write(new FileOutputStream(new File("yourpathhere")));
    document.close();
    

提交回复
热议问题