The code below generates an error: Stack Empty
Spire.Doc: 5.8.13.3040
- Code: Select all
DataTable parent = new DataTable("Parent");
parent.Columns.Add("Id");
DataTable childCollection1 = new DataTable("ChildCollection1");
childCollection1.Columns.Add("ParentId");
childCollection1.Columns.Add("Content");
DataTable childCollection2 = new DataTable("ChildCollection2");
childCollection2.Columns.Add("ParentId");
childCollection2.Columns.Add("Content");
parent.Rows.Add("1");
//childCollection1.Rows.Add("1", "test1");
childCollection2.Rows.Add("1", "test2");
DataSet dataSet = new DataSet();
dataSet.Tables.Add(parent);
dataSet.Tables.Add(childCollection1);
dataSet.Tables.Add(childCollection2);
List<DictionaryEntry> list = new List<DictionaryEntry>
{
new DictionaryEntry("Parent", String.Empty),
new DictionaryEntry("ChildCollection1", "ParentId = %Parent.Id%"),
new DictionaryEntry("ChildCollection2", "ParentId = %Parent.Id%")
};
Document document = new Document();
document.LoadFromFile("template.doc", FileFormat.Doc);
document.MailMerge.HideEmptyGroup = true;
document.MailMerge.ExecuteWidthNestedRegion(dataSet, list);
document.ViewSetup.DocumentViewType = DocumentViewType.PrintLayout;
document.SaveToFile("document.doc");
template:
- Code: Select all
«TableStart:Parent»
«TableStart:ChildCollection1»
Content: «Content»
«TableEnd:ChildCollection1»
#
«TableStart:ChildCollection2»
Content: «Content»
«TableEnd:ChildCollection2»
«TableEnd:Parent»
Thanks,
Damian