Solved

How to find sections in Word document Using Open XML

Posted on 2014-10-09
1
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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