从内存中读取WordprocessingDocument并使用OpenXml保存到AddAlternativeFormatImportPart

时间:2012-01-15 20:00:27

标签: c# ms-word openxml openxml-sdk docx

这项工作很好:

MemoryStream ms = //do some in memory on WordprocessingDocument ;
AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart(
                    AlternativeFormatImportPartType.WordprocessingML,
                    altChunkId);  
using(var fs = new FileStream(@"c:\\temp\\1.docx", FileMode.Create, FileAccess.ReadWrite,FileShare.Read))
        ms.WriteTo(fs);

using(FileStream fs = new FileStream(@"c:\\temp\\1.docx", FileMode.Open, FileAccess.Read))
        chunk.FeedData(fs);

无法正确读取内存流WordprocessingDocument并使用OpenXml保存到另一个AddAlternativeFormatImportPart而不保存到光盘

MemoryStream ms = //do some in memory on WordprocessingDocument ;
chunk.FeedData(fs);

怎么做?

这对我很有帮助

MemoryStream ms = //do some in memory on WordprocessingDocument ;
ms.Seek(0, SeekOrigin.Begin);
chunk.FeedData(ms);

0 个答案:

没有答案