public interface IMailMergeDataSource
When a data source is created, it should be initialized to point to BOF (before the first record). The Aspose.Words mail merge engine will invoke moveNext() to advance to next record and then invoke M:Aspose.Words.MailMerging.IMailMergeDataSource.GetValue(System.String,System.Object@) for every merge field it encounters in the document or the current mail merge region.
MailMerge| Modifier and Type | Method and Description |
|---|---|
IMailMergeDataSource |
getChildDataSource(java.lang.String tableName)
The Aspose.Words mail merge engine invokes this method when it encounters a beginning of a nested mail merge region.
|
java.lang.String |
getTableName()
Returns the name of the data source.
|
boolean |
getValue(java.lang.String fieldName,
Ref fieldValue) |
boolean |
moveNext()
Advances to the next record in the data source.
|
java.lang.String getTableName()
throws java.lang.Exception
If you are implementing IMailMergeDataSource, return the name of the data source from this property.
Aspose.Words uses this name to match against the mail merge region name specified in the template document. The comparison between the data source name and the mail merge region name is not case sensitive.
java.lang.Exceptionboolean moveNext()
throws java.lang.Exception
java.lang.Exceptionboolean getValue(java.lang.String fieldName,
Ref fieldValue)
throws java.lang.Exception
java.lang.ExceptionIMailMergeDataSource getChildDataSource(java.lang.String tableName) throws java.lang.Exception
When the Aspose.Words mail merge engines populates a mail merge region with data and encounters the beginning of a nested mail merge region in the form of MERGEFIELD TableStart:TableName, it invokes getChildDataSource(java.lang.String) on the current data source object. Your implementation needs to return a new data source object that will provide access to the child records of the current parent record. Aspose.Words will use the returned data source to populate the nested mail merge region.
Below are the rules that the implementation of getChildDataSource(java.lang.String) must follow.
If the table that is represented by this data source object has a related child (detail) table with the specified name, then your implementation needs to return a new IMailMergeDataSource object that will provide access to the child records of the current record. An example of this is Orders / OrderDetails relationship. Let's assume that the current IMailMergeDataSource object represents the Orders table and it has a current order record. Next, Aspose.Words encounters "MERGEFIELD TableStart:OrderDetails" in the document and invokes getChildDataSource(java.lang.String). You need to create and return a IMailMergeDataSource object that will allow Aspose.Words to access the OrderDetails record for the current order.
If this data source object does not have a relation to the table with the specified name, then you need to return a IMailMergeDataSource object that will provide access to all records of the specified table.
If a table with the specified name does not exist, your implementation should return null.
tableName - The name of the mail merge region as specified in the template document. Case-insensitive.java.lang.Exception