0
有沒有寫入OpenXmlPartReader
正在讀取的同一OpenXmlPart
的方法?我要去檢測讀者的東西,並可能用OpenXmlWriter
來寫東西。這裏是行不通的樣本:寫入正在讀取的同一個OpenXmlPart
var ms = new MemoryStream();
var doc = WordprocessingDocument.Create(ms, WordprocessingDocumentType.Document);
MainDocumentPart part = doc.AddMainDocumentPart();
part.Document = new Document(new Body(new Paragraph(), new Paragraph()));
doc.Save();
var stream = part.GetStream();
var reader = OpenXmlReader.Create(stream);
var writer = OpenXmlWriter.Create(stream);
reader.Read(); // read w:document
reader.ReadFirstChild(); // read w:body
reader.ReadFirstChild(); // read 1st w:p
writer.WriteElement(new Table()); // try to insert w:tbl
doc.Save(); // observe only the 2 paragraphs in the `w:body`.
它看起來像蓋下的Open XML SDK使用幕後XmlReader
和XmlWriter
,所以也許有一種方法來同步這些?