Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for additional information. You can try using the following code as a workaround.
doc.MailMerge.RemoveEmptyParagraphs = true;
doc.MailMerge.UseNonMergeFields = false;
doc.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeFieldEvent);
doc.MailMerge.Execute(dt);
//Get collection of field Starts
NodeCollection starts = doc.GetChildNodes(NodeType.FieldStart, true);
ArrayList cellsList = new ArrayList();
foreach (FieldStart start in starts)
{
if (start.FieldType == FieldType.FieldMergeField)
{
Cell cell = start.GetAncestor(NodeType.Cell) as Cell;
if (cell != null && !cellsList.Contains(cell))
cellsList.Add(cell);
}
}
//Remove content from cells without values
foreach (Cell cell in cellsList)
{
cell.RemoveAllChildren();
}
doc.MailMerge.DeleteFields();
Also, I saw that there is IF fields in your template. Note that Aspose.Words does not evaluate IF fields. See FAQ from more information.
Best regards.