Open XML: Word - получение всей вложенной таблицы из sdtBlock-> sdtContent - PullRequest
0 голосов
/ 05 марта 2019

enter image description here

У меня есть такая структура в моем слове документа.Необходимо извлечь все таблицы из тела из SdtBlock-> SdtContentBlock-> Table

 using (WordprocessingDocument formDoc = WordprocessingDocument.Open(destinationFile, true))
        {
            var FirstHeadingParagraph = new List<Paragraph>();
            var SecondHeadingParagraph = new List<Paragraph>();
            FirstHeadingParagraph = formDoc.MainDocumentPart.Document.Body.OfType<Paragraph>()
                                    .Where(p => p.ParagraphProperties != null &&
                                    p.ParagraphProperties.ParagraphStyleId != null &&
                                    p.ParagraphProperties.ParagraphStyleId.Val.Value.Contains("Heading2")).ToList();

            SecondHeadingParagraph = formDoc.MainDocumentPart.Document.Body.OfType<Paragraph>()
                                    .Where(p => p.ParagraphProperties != null &&
                                    p.ParagraphProperties.ParagraphStyleId != null &&
                                    p.ParagraphProperties.ParagraphStyleId.Val.Value.Contains("Heading3")).ToList();

            var AllTable= formDoc.MainDocumentPart.Document.Body.OfType<SdtBlock>().OfType<SdtContentBlock>().OfType<Table>().ToList();

Но получить список из 0 таблиц.

...