How can i create nested bulleted/Ordered lists with Novacode for docx? I've done some research but couldn't find anything, any help is appreciated.
Asked
Active
Viewed 1,172 times
2 Answers
0
Hope it's not too late, I've just figured it out a couple hours ago
class Program
{
static void Main(string[] args)
{
string docPath = "PATH TO YOUR OUTPUT WORD DOCUMENT" ;
var doc = DocX.Create(docPath);
var l = doc.AddList("Item #1", 0, ListItemType.Bulleted, 0);
doc.AddListItem(l, "Item #2");
doc.InsertList(l);
doc.Save();
}
}

Not_A_SysAdmin
- 126
- 6
-
thank u for your reply. But i can't see the nested list here, AddList creates a list, addlistItem adds items to the list created and then insertlist add it to document, isin't? – KARIMA Mar 06 '17 at 17:20
0
You should use the indent-level (parameter 2 of DocX.AddList(...)
and parameter 3 of DocX.AddListItem(...)
)
DocX doc = DocX.Create("filename.docx");
List list = doc.AddList("item 1", 0, ListItemType.Numbered);
doc.AddListItem(list, "item 2", 1);
doc.AddListItem(list, "item 3", 1);
doc.AddListItem(list, "item 4", 2);
doc.AddListItem(list, "item 5", 2);
doc.AddListItem(list, "item 6", 1);
doc.AddListItem(list, "item 7", 0);
doc.AddListItem(list, "item 8", 2);
doc.InsertList(list);
This produces:

Karim Ayachi
- 547
- 5
- 11