TXTextControl.DocumentServer.MailMerge.Merge Method

Merges given data into the loaded document template. The supported format of the merge fields can be found in the ASP.NET User's Guide.

Merge(DataTable, Boolean)

Merges the loaded template with the data of a specific System.Data.DataTable. The second parameter specifies whether the single documents should be merged into one document or splitted into separate documents.

[C#]
public void Merge(System.Data.DataTable mergeData, bool append);
[Visual Basic]
Public Sub Merge(ByVal mergeData As System.Data.DataTable, ByVal append As Boolean)
Parameter Description
mergeData

Specifies a System.Data.DataTable that contains the merge data.

append

Specifies whether the single documents should be merged into one document or split into separate documents.

Merge(DataTable)

Does the same as Merge(System.Data.DataTable mergeData, bool append) with parameter “append” set to true.

[C#]
public void Merge(System.Data.DataTable mergeData);
[Visual Basic]
Public Sub Merge(ByVal mergeData As System.Data.DataTable)
Parameter Description
mergeData

Specifies a System.Data.DataTable that contains the merge data.

Merge(Boolean)

Merges data into the template using a data base connection given through a data source configuration file or data source configuration XML data. (See also ReportDataSourceConfigFile property and ReportDataSourceConfig property)

[C#]
public void Merge(bool append);
[Visual Basic]
Public Sub Merge(ByVal append As Boolean)
Parameter Description
append

Specifies whether the single documents should be merged into one document or split into separate documents.

Merge()

Does the same as method Merge(bool append) with parameter “append” set to true.

[C#]
public void Merge();
[Visual Basic]
Public Sub Merge()

Example

The following example merges a template that contains two merge fields: name and company.

[C#]
DataTable mergeData = new DataTable();
mergeData.Columns.Add("name");
mergeData.Columns.Add("company");

mergeData.Rows.Add(new object[] { "Peter Jackson", "Text Control GmbH" });
mergeData.Rows.Add(new object[] { "Jack Petersen", "The Imaging Source LLC" });

mailMerge1.LoadTemplate("template.doc", TXTextControl.DocumentServer.FileFormat.MSWord);

mailMerge1.Merge(mergeData, true);

TXTextControl.SaveSettings sSettings = new TXTextControl.SaveSettings();
mailMerge1.SaveDocument("results.pdf", TXTextControl.StreamType.AdobePDF, sSettings);
[Visual Basic]
Dim MergeData As New DataTable()
MergeData.Columns.Add("name")
MergeData.Columns.Add("company")

MergeData.Rows.Add(New Object() {"Peter Jackson", "Text Control GmbH"})
MergeData.Rows.Add(New Object() {"Jack Petersen", "The Imaging Source LLC"})

MailMerge1.LoadTemplate("template.doc", TXTextControl.DocumentServer.FileFormat.MSWord)

MailMerge1.Merge(MergeData, True)

Dim SSettings As New TXTextControl.SaveSettings()
MailMerge1.SaveDocument("results.pdf", TXTextControl.StreamType.AdobePDF, SSettings)

See Also