سؤال

How can I get the list of shapes (textboxs) in an SdtBlock element using Open XML SDK?

Regards.

هل كانت مفيدة؟

المحلول

In order to grab all the shapes in a WordProcessingDocument you can use linq to traverse all the descendants of the body:

using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(stream, true))
{
    IEnumerable<DocumentFormat.OpenXml.Vml.Shape> shapes = wordDoc.MainDocumentPart.Document.Body.Descendants<DocumentFormat.OpenXml.Vml.Shape>();
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top