Document document = new Document();Section section = document.AddSection();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);Paragraph paragraph = section.AddParagraph();paragraph.AppendText("The first item");paragraph.ApplyStyle(BuiltinStyle.Heading1);paragraph.ListFormat.ApplyStyle("levelstyle");paragraph = section.AddParagraph();paragraph.AppendText("The second item");paragraph.ApplyStyle(BuiltinStyle.Heading1);paragraph.ListFormat.ApplyStyle("levelstyle");paragraph = section.AddParagraph();paragraph.AppendText("The first sub-item");paragraph.ApplyStyle(BuiltinStyle.Heading2);paragraph.ListFormat.ListLevelNumber = 1;paragraph.ListFormat.ApplyStyle("levelstyle");paragraph = section.AddParagraph();paragraph.AppendText("The second sub-item");paragraph.ApplyStyle(BuiltinStyle.Heading2);paragraph.ListFormat.ContinueListNumbering();paragraph.ListFormat.ApplyStyle("levelstyle");paragraph = section.AddParagraph();paragraph.AppendText("A sub-sub-item");paragraph.ApplyStyle(BuiltinStyle.Heading5);paragraph.ListFormat.ListLevelNumber = 2;paragraph.ListFormat.ApplyStyle("levelstyle");paragraph = section.AddParagraph();paragraph.AppendText("The third item");paragraph.ApplyStyle(BuiltinStyle.Heading1);paragraph.ListFormat.ApplyStyle("levelstyle");document.SaveToFile(@"result.docx", FileFormat.Docx);
Login to post response