open xml Numbered list

7.8k views Asked by At

I need to get w:lvl text from w:ilvl I was able to get w:ilvl value but got stuck on how to proceed from here How do I link w:ilvl to w:numbering (I know I have to use w:ilvl, but how to do it from the code side) in .net? code snippet for document.xml is pasted below. I need to get the cell text form w:ilvl

<w:tc>
  <w:tcPr>
    <w:tcW w:w="990" w:type="dxa" />
  </w:tcPr>
  <w:p w:rsidRPr="006D6DAA" w:rsidR="008F1408" w:rsidP="00012A9D" w:rsidRDefault="008F1408">
    <w:pPr>
      <w:pStyle w:val="Table-Left" />
      <w:numPr>
        <w:ilvl w:val="0" />
        <w:numId w:val="13" />
      </w:numPr>
      <w:rPr>
        <w:sz w:val="18" />
      </w:rPr>
    </w:pPr>
  </w:p>
</w:tc>
1

There are 1 answers

4
Eric White On BEST ANSWER

Processing numbered items in WordprocessingML is not trivial. The MSDN article Working with Numbered Lists in Open XML WordprocessingML discusses the issue in detail.

Fortunately, you don't have to do this yourself. There is a module, ListItemRetriever, in PowerTools for Open XML that will retrieve the list item in text form for any paragraph. The screen-cast titled WordprocessingML Numbering demonstrates how to use ListItemRetriever.

Another module you may be interested in is the FormattingAssembler module, also part of PowerTools for Open XML. This module not only retrieves the list items for you, it also retrieves the exact formatting, including font, colors, font attributes, and etc. of each list item.

PowerTools for Open XML are licensed using the Microsoft Public License, which means that it is free as in beer, and free as in speech. You can use it in a commercial product, and it doesn't impact the licensing of the remainder of your project.