Mailmerging Nested Tables is failing.

Hi, I have been trying to use Syncfusion.DocIO.Net.Core v31.2.2 to process a Word document containing two nested merge tables (initially on an Azure function project, but have moved to a console app for testing), however every time it runs it generates a file with no data. I have tried similar using ExecuteGroups() with a single table and this seems to work, however when using ExecuteNestedGroups() it silently fails. A snippet of my code is below:


var ds = new DataSet();


var invoice = new DataTable("Invoice");
invoice.Columns.Add("InvoiceID", typeof(int));
invoice.Columns.Add("InvoiceDate", typeof(string));
invoice.Rows.Add(1, "2025-10-15");
ds.Tables.Add(invoice);


var sundries = new DataTable("Sundries");
sundries.Columns.Add("InvoiceID", typeof(int));
sundries.Columns.Add("Name", typeof(string));
sundries.Rows.Add(1, "Widget");
sundries.Rows.Add(1, "Cable");
ds.Tables.Add(sundries);


ds.Relations.Add("Invoice_Sundries",
    invoice.Columns["InvoiceID"], sundries.Columns["InvoiceID"], false);


using var doc = new WordDocument("MailMergeTemplates/NestedMergeTest.docx", Syncfusion.DocIO.FormatType.Docx);
var roots = new ArrayList { new DictionaryEntry("Invoice", "Invoice") };


doc.MailMerge.ExecuteNestedGroup(ds, roots);


doc.Save("result.docx");

I have also attached my Word document template, I appreciate any help.

Thanks


Attachment: NestedMergeTest_18c30447.docx

1 Reply

KP Kathiresan Paranthaman Syncfusion Team October 16, 2025 02:08 PM UTC

Hi Tao,
Based on the details provided, we understand that your requirement is to perform a nested group mail merge using a DataTable in DocIO. Upon further analysis of the given template, we noticed that although it includes TableStart and TableEnd merge fields, the merge fields themselves are not placed inside a table.

To perform mail merge within the document body content, it is recommended to use BeginGroup and EndGroup regions instead of table-based merge fields. We have modified your template accordingly and prepared a working sample, which is attached below for your reference.

If this solution does not meet your requirements, please share the complete details along with the relevant document. We will review it and provide further assistance.

User Guide:
Group Mail merge in C# | DocIO | Syncfusion
Mail merge for nested groups in C# | DocIO | Syncfusion

Regards,
Kathiresan.


Attachment: Sample_NestedMailMerge_bff6428e.zip

Loader.
Up arrow icon