i create word document form MemoryStream using openxml
Here is the code I am using:
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();
}
i can save one MemoryStream to FileStream ,and save to .docx file than open it, but how could i merge two MemoryStream word document as one word document in MemoryStream or FileStream than save it?
Merging two documents using Open XML is quite a demanding task. I suggest you to use either
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.