【发布时间】:2017-03-03 01:24:42
【问题描述】:
我使用 openxml 创建 Word 文档表单 MemoryStream
这是我正在使用的代码:
System.IO.MemoryStream ms1=new MemoryStream();
using (var mainDoc = WordprocessingDocument.Create(ms1, WordprocessingDocumentType.Document))
{
mainDoc.AddMainDocumentPart();
mainDoc.MainDocumentPart.Document =
new Document(new Body(new Paragraph(new Run(new Text("Hello World 1!")))));
mainDoc.MainDocumentPart.Document.Save();
}
System.IO.MemoryStream ms2 = new MemoryStream();
using (var mainDoc = WordprocessingDocument.Create(ms2,WordprocessingDocumentType.Document))
{
mainDoc.AddMainDocumentPart();
mainDoc.MainDocumentPart.Document =
new Document(new Body(new Paragraph(new Run(new Text("Hello World 2!")))));
mainDoc.MainDocumentPart.Document.Save();
}
我可以将一个 MemoryStream 保存到 FileStream 中,然后保存到 .docx 文件中 打开它,但是如何将两个 MemoryStream word 文档合并为 MemoryStream 或 FileStream 中的一个 word 文档而不是保存它?
【问题讨论】:
-
你看过OpenXmlPowerTools吗?更多信息Eric White's site