Solved

How to find sections in Word document Using Open XML

Posted on 2014-10-09
1
179 Views
Last Modified: 2014-10-14
Hi Team,

Can u plz provide code to find sections  in word document using open XML
0
Comment
Question by:mannevenu26
1 Comment
 
LVL 1

Accepted Solution

by:
Prashant Jagdale earned 500 total points
ID: 40372368
Try using code below:
 static void FindSections(string filename)
        {
            using (WordprocessingDocument wpDoc = WordprocessingDocument.Open(filename, true))
            {
                MainDocumentPart mpDoc = wpDoc.MainDocumentPart;
                List<ParagraphProperties> pProps = mpDoc.Document.Descendants<ParagraphProperties>()
                .Where(pPr => IsContainsSection(pPr)).ToList();
                foreach (ParagraphProperties pPr in pProps)
                {
                    SectionProperties pSP= pPr.GetFirstChild<SectionProperties>();
                }
                
            }
        }
        static bool IsContainsSection(ParagraphProperties pPr)
        {
            SectionProperties sectPr = pPr.GetFirstChild<SectionProperties>();
            if (sectPr == null)
                return false;
            else
                return true;
        }

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XML to SQL Table using c# 5 47
ASP:DataGrid and how to bind to a BoundColumn 8 30
Data Saving(2) 2 26
getting id from database 5 24
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now