Can someone please guide on how to generate nested number list.
Need to generate:
1. One
2. Two
2.1 TwoPointOne
2.2 TwoPointTwo
2.2.1 TwoTwoOne
3. Three
//create a new doc document
Document document = new Document();
//add one section
Section section = document.AddSection();
//Create a new paragraph
ListStyle listStyle = new ListStyle(document, ListType.Numbered);
listStyle.Name = "levelstyle";
listStyle.Levels[0].PatternType = ListPatternType.Arabic;
listStyle.Levels[1].NumberPrefix = "\x0000.";
listStyle.Levels[1].PatternType = ListPatternType.Arabic;
listStyle.Levels[2].NumberPrefix = "\x0000.\x0001.";
listStyle.Levels[2].PatternType = ListPatternType.Arabic;
document.ListStyles.Add(listStyle);
//apply the custom style
Paragraph paragraph = section.AddParagraph();
paragraph.AppendText("One");
paragraph.ListFormat.ApplyStyle("levelstyle");
paragraph = section.AddParagraph();
paragraph.AppendText("Two");
paragraph.ListFormat.ApplyStyle("levelstyle");
paragraph = section.AddParagraph();
paragraph.AppendText("TwoPointOne");
paragraph.ListFormat.ListLevelNumber = 1;
paragraph.ListFormat.ApplyStyle("levelstyle");
paragraph = section.AddParagraph();
paragraph.AppendText("TwoPointTwo");
paragraph.ListFormat.ContinueListNumbering();
paragraph.ListFormat.ApplyStyle("levelstyle");
paragraph = section.AddParagraph();
paragraph.AppendText("TwoTwoOne");
paragraph.ListFormat.ListLevelNumber = 2;
paragraph.ListFormat.ApplyStyle("levelstyle");
paragraph = section.AddParagraph();
paragraph.AppendText("Three");
paragraph.ListFormat.ApplyStyle("levelstyle");
//Save doc file.
document.SaveToFile(@"result.docx", FileFormat.Docx);