Get lists in word using c#

Home Forums WordprocessingML Get lists in word using c#

This topic contains 2 replies, has 2 voices, and was last updated by  mayankgaur.in@gmail.com 3 weeks, 6 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4308

    How to fetch bullet/numbered lists using c# ?

    #4313

    Eric White
    Keymaster

    There is the ListItemRetriever module in Open-Xml-PowerTools, which will return the list item (the actual numbering / bulleting) for any paragraph in a document. This module is used by the WmlToHtmlConverter module, which converts a document to HTML that is formatted with CSS.

    What are you doing with the bulleted / numbered lists? What is your scenario?

    #4316

    Hi Eric,
    I need to fetch all lists from documents, with their parents. For Instance ,

    Companies List:-
    1. ABC
    2. XYZ
    3. KLM.
    Places to visit :-
    1. International Space Station(ISS)
    2. Poles of Earth

    I need to make them sort like,
    Public Class Parent
    {

    public string Name{get;set;}
    public HashSet<Children>childrens{get;set;}
    }
    HashSet<Parent> parentModel= new HashSet<Parent>();
    using (WordprocessingDocument doc = WordprocessingDocument.Open(docxFile, true))
    {
    Body body = doc.MainDocumentPart.Document.Body;
    foreach (Paragraph paragraph in paragraphs)
    {

    parent.Name= paragraph.InnerText;
    parentlist.Add(parent);
    model.parents = parentlist;
    }
    }
    //Thats how I got parent But I want child like that
    Parent[0] Companies List
    Child[0]ABC
    Child[1]XYZ
    Child[2]KLM
    Parent[1] Places to visit
    Child[0]International Space Station(ISS)
    Child[1]Poles of Earth

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.