@awais.hafeez Can you share the example. I cant see the example.
Please see these input/output Word DOCX documents (SumAvgExample.zip (18.7 KB)) and try running the following C# code:
Document doc = new Document("E:\\Temp\\SumAvgExample (1)\\SumAvgExample.docx");
doc.MailMerge.ExecuteWithRegions(GetDataTable());
doc.UpdateFields();
doc.Save("E:\\Temp\\SumAvgExample (1)\\20.5.docx");
private static DataTable GetDataTable()
{
DataTable dataTable = new DataTable("tbl");
dataTable.Columns.Add(new DataColumn("mf1"));
dataTable.Columns.Add(new DataColumn("mf2"));
DataRow dataRow;
for (int i = 1; i < 5; i++)
{
dataRow = dataTable.NewRow();
dataRow[0] = i;
dataRow[1] = i;
dataTable.Rows.Add(dataRow);
}
return dataTable;
}
Hope, this helps.
A post was split to a new topic: Calculate SUM & AVERAGE Formula Fields during Mail Merge using C# Example