Free Support Forum - aspose.com

How to restart alphabetical numbering using aspose.words (.net)

addparagraph("this is simple paragraph", "GSA List Paragraph (alpha)");

public void addparagraph(string Text, string stylename = null, int contiontocheck = 0)
{
builder.Font.ClearFormatting();
builder.ParagraphFormat.ClearFormatting();
if (stylename == null)
stylename = "Normal";
//if (stylename == "GSA List Paragraph (alpha)" && contiontocheck == 2)
// builder.ListFormat.ListLevel.RestartAfterLevel = 1;
builder.ParagraphFormat.StyleName = stylename;
builder.Writeln(Text);
}

Hi
I've custom styles which brings up alphabetical numbering list
I'm trying to build a generic and dynamic method to build word document. So, it's not possible to specify the section number and paragraph location at run time.
How can I programmatically restart numbering ?
Responses would be greatly appreciated. Thanks in advance.
Hi there,

Thanks for your inquiry. In your case, you need to copy the existing list and apply it to paragraphs. Following code example shows how to copy a list and apply it to a paragraph. Hope this helps you.

If you face any issue, please share your input and expected output documents. We will then provide you more information about your query.

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

//Get the second paragaph of document

Paragraph paragraph = (Paragraph)doc.GetChild(NodeType.Paragraph, 1, true);

Aspose.Words.Lists.List newList = doc.Lists.AddCopy(paragraph.ListFormat.List);

//Get the third paragaph of document

Paragraph fourth_paragraph = (Paragraph)doc.GetChild(NodeType.Paragraph, 2, true);

fourth_paragraph.ListFormat.List = newList;

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToDocumentEnd();

//Apply the list using DocumentBuilder

newList = doc.Lists.AddCopy(paragraph.ListFormat.List);

builder.ListFormat.List = newList;

builder.Writeln("this is simple paragraph");

builder.Writeln("this is simple paragraph");

doc.Save(MyDir + "17.5.docx");

Glad it Worked! Thanks.