Hello,
I’m getting an InvalidOperationException (Stack Empty) with the attached template.
I’m using this code to reproduce this issue :
Document doc = new Document(@"C:\partage\PileVide.docx");
DataSet ds = new DataSet();
for (int i = 0; i < 9; i++)
{
ds.Tables.Add();
ds.Tables[i].Columns.Add("test");
ds.Tables[i].Rows.Add("a");
}
doc.MailMerge.ExecuteWithRegions(ds);
Stack trace :
à System.Collections.Stack.Pop()
à xfbd1009a0cbb9842.x109ecce6e2a0da51.x47f176deff0d42e2()
à Aspose.Words.Fields.Field.x58daf9beaf8b1ae0()
à Aspose.Words.Fields.Field.x42a25ae95099edb8(x5e36356bc92c609b x0f7b23d1c393aed9)
à Aspose.Words.Fields.Field.x295cb4a1df7a5add(x5e36356bc92c609b x0f7b23d1c393aed9)
à xfbd1009a0cbb9842.xfedf115fd9c03862.x4e3cfc222c92cda7(Field xe01ae93d9fe5a880, x5e36356bc92c609b x0f7b23d1c393aed9)
à xfbd1009a0cbb9842.xbf9ddf72e1283af9.x18dfca7c5fd2402f()
à xfbd1009a0cbb9842.xfedf115fd9c03862.xdd6cf0348a23f220(xcf417e2db4fe9ed3 xe00c282e1a49fcfb)
à xfbd1009a0cbb9842.xfedf115fd9c03862.xdf269951086089ce(x6435b7bbb0879a04 xa942970cc8a85fd4)
à xe86f37adaccef1c3.xc5c3f438428cb03b.xdeeb682062ef79a5()
à Aspose.Words.Reporting.MailMerge.ExecuteWithRegions(IMailMergeDataSourceRoot dataSourceRoot)
à Aspose.Words.Reporting.MailMerge.ExecuteWithRegions(DataSet dataSet)
As information, I tried to reproduce the issue using this code to create a template. I don’t see any difference with the attached template, but it works fine with this code …
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertField(" MERGEFIELD TableStart:TABLE1 ");
Field field = builder.InsertField("IF \"-1\" = \"-1\" \"a " + Environment.NewLine);
builder.InsertField(" MERGEFIELD TableEnd:TABLE1 ");
builder.MoveTo(field.Separator);
builder.InsertField(" MERGEFIELD TableStart:TABLE8 ");
builder.InsertNode(new Run(doc, " b "));
builder.InsertField(" MERGEFIELD TableEnd:TABLE8 ");
builder.InsertNode(new Run(doc, " c" "" "));
I reproduce this issue with Aspose.Word 10.5.0.
I tried with Aspose 11.7.0, I’m getting this exception : System.InvalidOperationException : Mail merge regions ‘TABLE1’ and ‘TABLE1’ overlap. Two regions cannot start/end in the same paragraph or occupy the same table row.
Nested Region are no more supported by Aspose Word ?