Free Support Forum - aspose.com

How to get List Label using Aspose.Words for .NET

I have Number Format “\0.\u0004”. How convert it to decimal ?

@mesteruh

Could you please ZIP and attach your input and expected output Word documents? We will then provide you more information about your query.

in word file i have numeric fields. Paragraph.Range.Text return \0.\u0004. I need decimal view
image.png (25.6 KB)

@mesteruh

In your case, we suggest you please use the ListLabel.LabelString property as shown below to get the correct value of list label. Hope this helps you.

If you still face problem, please ZIP and attach your input Word document and expected output here for our reference. We will then provide you code example according to your requirement.

Document doc = new Document(MyDir + "Rendering.docx");
doc.UpdateListLabels();

NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true);

// Find if we have the paragraph list. In our document our list uses plain arabic numbers,
// which start at three and ends at six
foreach (Paragraph paragraph in paras.OfType<Paragraph>().Where(p => p.ListFormat.IsListItem))
{
    Console.WriteLine($"List item paragraph #{paras.IndexOf(paragraph)}");

    // This is the text we get when actually getting when we output this node to text format
    // The list labels are not included in this text output. Trim any paragraph formatting characters
    string paragraphText = paragraph.ToString(SaveFormat.Text).Trim();
    Console.WriteLine($"\tExported Text: {paragraphText}");

    ListLabel label = paragraph.ListLabel;
    // This gets the position of the paragraph in current level of the list. If we have a list with multiple level then this
    // will tell us what position it is on that particular level
    Console.WriteLine($"\tNumerical Id: {label.LabelValue}");

    // Combine them together to include the list label with the text in the output
    Console.WriteLine($"\tList label combined with text: {label.LabelString} {paragraphText}");
}

FH1_S_P000_&&&&&&&&&&&&&_000_FY_0002_E.zip (108.7 KB)

12 page. Label LabelValue is always 0

@mesteruh

We have tested the scenario using the latest version of Aspose.Words for .NET 20.11 and have not found the shared issue. So, please use Aspose.Words for .NET 20.11.