We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error with numbering with Merge function

If you prepare a letter for mailmerge, and you are using numbering format, then in the merged letter, the numbering does NOT restart on each letter. Even if the setting on the numbering is set to “Start New List” in Microsoft Word, the numbering is continuously.

Is there something special to code with Aspose Merge function? Or is this an error?

Hi

Thanks for your inquiry. Could you please attach your template for testing? I will investigate the issue and provide you more information.

Best regards.

Please find attached a zip file with following files:

  • template.doc: the serialletter template
  • csv_datasource.csv: file with testdata, which you can attach as datasource
  • merged_with_Aspose.doc: Merged letter, using Aspose (see numbering of the numbered items: it is continuously, which is wrong)
  • merged_with_microsoft_word.doc: Merged letter, using Microsoft Word (see numbering, which is correct)

Hi

Thank you for additional information. I managed to reproduce the problem and created new issue #6385 in our defect database. I will notify you as soon as it is fixed.

Best regards.

Hi

It’s now almost a year ago since I’ve posted this problem, and I was wondering, in which Version of Aspose.Words the issue #6385 will be fixed.

Best Regards

Thomas

Hi Thomas,

Thanks for your request. Unfortunately, the issue is still unresolved.

If you need, I can try to create a workaround you for while you are waiting for a fix. The simplest workaround, I can suggest you, is avoiding using numbered lists in your document. For example, you can use bulleted lists or replace numbered list with plain text.

Best regards.

Hi Alexey

How would you make the workaround? With a special Version of Aspose.Words, or with .NET Code to manipulate the merged document?

Well, the suggestion, to avoid using numbered lists are we doing for a year now. Do you have an idea, when this issue will be fixed?

Best Regards

Thomas

Hi Tomas,

Thanks for your request. If you need, I can try to create a programmatic workaround for you.

Unfortunately, I cannot promise you anything regarding this issue at the moment. We are reworking our Reporting (Mail Merge) Engine now. I think, once we finished this work this issue will be also fixed. However, I cannot give an exact date.

Best regards.

Hi Alexey

So, due to the unknown fix date, I would like that you try to create a programmatic workaround. If there is a way to fix this issue with some code, that would help us a lot.

Thanks for your efforts.

Best regards

Thomas

Hi

Thanks for your request. You can try using the following code as a workaround:

// Create dummy datasource.

DataTable data = new DataTable();

data.Columns.Add(“item1”);

data.Columns.Add(“item2”);

data.Columns.Add(“item3”);

data.Columns.Add(“item4”);

data.Columns.Add(“item5”);

data.Columns.Add(“item6”);

data.Columns.Add(“item7”);

data.Columns.Add(“item8”);

data.Columns.Add(“item9”);

data.Columns.Add(“item10”);

// Add some dummy data.

for(int i =0; i<10; i++)

{

data.Rows.Add(new object[] { “item1”, “item2”, “item3”, “item4”, “item5”,

“item6”, “item7”, “item8”, “item9”, “item10” });

}

// Open template document.

Document doc = new Document(@“Test001\in.doc”);

// Execute mail merge.

doc.MailMerge.Execute(data);

// In this example we suppose that the original template has only one section.

// In this case, one section for each record will be created.

// So we can loop through all sections in the document and restart numberign of lists.

// We will use DocuemntVisitor to achieve this.

RestartNumberingHelper helper = new RestartNumberingHelper();

doc.Accept(helper);

// Save output document.

doc.Save(@“Test001\out.doc”);

=======================================================================

private class RestartNumberingHelper : DocumentVisitor

{

public override VisitorAction VisitSectionStart(Section section)

{

newList = null;

oldList = null;

return VisitorAction.Continue;

}

public override VisitorAction VisitParagraphStart(Paragraph paragraph)

{

// Check if the curren tparagraph is list item.

if(paragraph.IsListItem)

{

// If so we need to create a copy of the list and reset the list.

if (newList == null || (!paragraph.ListFormat.List.Equals(oldList) && newList != null))

{

oldList = paragraph.ListFormat.List;

newList = paragraph.Document.Lists.AddCopy(oldList);

}

paragraph.ListFormat.List = newList;

}

return VisitorAction.Continue;

}

private List oldList;

private List newList;

}

I also attached my test files.

Hope this helps.

Best regards.

Thanks you very much.

It works great for me.

Daljit Singh

The issues you have found earlier (filed as WORDSNET-1860) have been fixed in this Aspose.Words for .NET 19.12 update and this Aspose.Words for Java 19.12 update.