MailMerge.Execute issue when looping through the rows of an Excel file

Hi,

We’re using Aspose.Words nuget v23.5.0 on a .NET Framework 4.8

We’ve a function looping through the datarows of an Excel file and merging the data into a new Words document (1 document for each row of the Excel file).

We’ve had few cases where passing a certain amount of row (~60), the generated documents was referencing data of the first row of the file instead of the correct one. So the document n°62 contains data of the row 1 instead of the 62.

The code is nothing fancy :

var file = new DataTable();
foreach (DataRow row in file.Rows)
{
    var testDoc= new Document("text.docx");
    var dstDoc = (Document)testDoc.Clone(true);
    dstDoc.MailMerge.Execute(row);
}

Is there anything wrong with the approach ?

Thanks in advance for your help

@fasbt Unfortunately, I cannot reproduce the problem on my side. Here is simple code I have used for testing:

DataTable dt = new DataTable("Table");
dt.Columns.Add("value");
for (int i = 0; i < 10; i++)
    dt.Rows.Add(i);

foreach (DataRow dr in dt.Rows)
{
    Document doc = new Document(@"C:\Temp\in.docx");
    doc.MailMerge.Execute(dr);
    doc.Save($@"C:\Temp\out_{dt.Rows.IndexOf(dr)}.docx");
}

The template contains one mergefield.

Please make sure template is not replaced after executing the first iteration.