Hi
1)I have a template with some merge field in header and footer:
1.Header:
<<TableStart Quote>> <<field1>> <<TableEnd>>
2.Main body:
<<TableStart Quote>> <<fieldX>> .... (other fields)
<<TableEnd>>
3.Footer:
<<TableStart Quote>> <<field66>> <<TableEnd>>
2)I am using my own MyDataSource:IMailMergeDataSource;
3)PROBLEM: when I call MailMerge.ExecuteWithRegions(myDS)
Only header is merged. The rest of the document is unchanged.
4)What I tried:
I called MailMerge.ExecuteWithRegions(myDS) 3 times, creating a new instance of MyDataSource every time:
MyDataSource myDS = new MyDataSource(data);
doc.MailMerge.ExecuteWithRegions(ds); //this merges header
MyDataSource myDS = new MyDataSource(data);
doc.MailMerge.ExecuteWithRegions(ds); //this merges main body
MyDataSource myDS = new MyDataSource(data);
doc.MailMerge.ExecuteWithRegions(ds); ////this merges footer
This approach seems to work but is this the right way to do this.
As far as i can see I need to call ExecuteWithRegions now as many times as there are <<TableStart Quote>>
mergefileds in my document as a single call seems to only do one of them?
I am sure this is not the way it is designed to behave by Aspose.
5)I wonder if this only happens with custom DataSources?
Or may be I did not implement one of the methods correctly in MyDataSource?
I would expect IMailMergeDataSource to have a method to reset it to original state which should be called by Aspose after all rows from the root DataTable (Quote in my case) are merged in the header and a new <> is encountered again?
I mean Aspose certainly allows opening a child table multiple times in the document as this works just fine (note 2 pairs of TableStart…TableEnd for table called FirstChild!):
<<TableStart aRootTable>>
<<TableStart FirstChild>>
<<TableEnd>>
<<TableStart FirstChild>>
<<TableEnd>>
<<TableEnd>>
So I kind of expected that the same would work for the root table, but it does not seem to (using MyDataSource - may work for System.Data.DataSet as Datasource?):
<<TableStart aRootTable>>
…
<<TableEnd>>
<<TableStart aRootTable>>
…
<<TableEnd>>
Note: I tried with DataSet and it does not handle situation either !
Thanks!
William