【发布时间】:2015-05-21 12:34:05
【问题描述】:
我最终试图将 docx 文件中的内容复制到剪贴板。到目前为止我想出的代码是:
package config;
public class buffer {
public static void main(String[] args) throws IOException, XmlException {
XWPFDocument srcDoc = new XWPFDocument(new FileInputStream("D:\\rules.docx"));
XWPFDocument destDoc = new XWPFDocument();
OutputStream out = new FileOutputStream("D:\\test.docx");
for (IBodyElement bodyElement : srcDoc.getBodyElements()) {
XWPFParagraph srcPr = (XWPFParagraph) bodyElement;
XWPFParagraph dstPr = destDoc.createParagraph();
dstPr.createRun();
int pos = destDoc.getParagraphs().size() - 1;
destDoc.setParagraph(srcPr, pos);
}
destDoc.write(out);
out.close();
}
}
这确实会获取项目符号,但会对其进行编号。我想保留原来的项目符号格式。有没有办法做到这一点?
【问题讨论】:
标签: java apache-poi docx docx4j