Solved

How to find sections in Word document Using Open XML

Posted on 2014-10-09
1
190 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Regex validation 2 25
Getting error in connectionstring with Excel. 30 32
HTML - Color not displaying correctly in EMAIL. 6 38
C# Gridview 1 33
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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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