Hi
Thanks for your request. Previously, it was required to
update page layout to be able to update TOC fields. Currently, since upon updating
fields, Aspose.Words also updates page layout, this is not required. So to
update TOC, you need only update fields.
Regarding the second problem, This occurs because when you
execute simple mail merge, the data source contains two rows, that is why
template is copied for the second record. To resolve the problem, you should
correct your code as shown below:
private void fillDataTable(DataTable
dt, Int32 rowCnt)
{
for (Int32 i = 0;
i < rowCnt; i++)
{
DataRow dr = dt.NewRow();
foreach (DataColumn
dc in dt.Columns)
{
if (dc.DataType == typeof(float))
{
dr[dc.ColumnName] = rnd.NextDouble();
}
else if (dc.DataType
== typeof(String))
{
dr[dc.ColumnName] = "test string"
+ Convert.ToDecimal(rnd.NextDouble()).ToString();
}
else if (dc.DataType
== typeof(DateTime))
{
dr[dc.ColumnName] = DateTime.Now.AddHours(rnd.NextDouble()).ToString();
}
}
dt.Rows.Add(dr);
}
}
Best regards,
Alexey Noskov
Developer/Technical Support
Aspose Auckland Team