我尝试使用apache poi XWPFDocument将解析后的文本从xml写入docx文件,但是在tmpParagraph.createRun()方法中它会抛出NPE,有什么建议吗?
public void dothis() throws ParserConfigurationException, SAXException, IOException{
in = new BufferedReader(new FileReader("P.xml"));
XWPFDocument document1 = new XWPFDocument();
XWPFParagraph tmpParagraph = document1.createParagraph();
XWPFRun tmpRun = (XWPFRun) tmpParagraph.createRun();
document1.write(new FileOutputStream(new File("post.docx")));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// Get the DOM Builder
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse("P.xml");
List<Elementt> empList = new ArrayList<>();