[英]How to convert Word document created from template by OpenXML into MemoryStream?
[英]how to merge multiple word document form MemoryStream using openxml
我使用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文檔合並為一個WordDocument在MemoryStream或FileStream中而不保存呢?
使用Open XML合並兩個文檔是一項艱巨的任務。 我建議您使用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.