Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用:
XWPFDocument 文档 = new XWPFDocument();
如何分配它以便它不会覆盖已经存在的文件?
以下将创建一个全新的空 XWPF Word 文档以供使用:
XWPFDocument document = new XWPFDocument();
而这将打开一个现有的进行编辑:
XWPFDocument document = new XWPFDocument(OPCPackage.open("MyFile.docx"));
或者,如果您有一个InputStream而不是一个文件:
InputStream
XWPFDocument document = new XWPFDocument(inputStream);