MailMerge Class |
Namespace: SautinSoft.Document.MailMerging
The MailMerge type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | ClearOptions |
Gets or sets a set of flags that specify what items should be removed during mail merge.
|
![]() | Document |
Gets the owner document.
|
![]() | FieldMappings |
Gets the mappings from field names to data source column names.
|
![]() | RangeEndPrefix |
Gets or sets a mail merge region end prefix.
|
![]() | RangeStartPrefix |
Gets or sets a mail merge region start prefix.
|
Name | Description | |
---|---|---|
![]() | ClearTemplate |
Remove all MergeFields from the current document.
|
![]() ![]() | Execute(Object) |
Executes a mail merge operation with specified data source.
|
![]() | Execute(Object, String) |
Executes a mail merge operation with specified range name and data source.
|
![]() | GetMergeFieldNames |
Gets a collection of mail merge field names available in the document.
|
![]() | RemoveMergeFields |
Removes all mail merge related fields
(MergeField,
MergeRec,
MergeSeq,
Next and
If)
from the document.
|
![]() | RemoveMergeFields(Boolean) |
Removes mail merge related fields from the document.
|
Name | Description | |
---|---|---|
![]() | FieldMerging |
Occurs when Field is merging with data source
value and can be used to customize the merging operation.
|
using System; using System.Data; using System.IO; using SautinSoft.Document; namespace Sample { class Sample { static void Main(string[] args) { TableReportWithRegions(); } /// <summary> /// Generates a table report with regions using XML document as a data source. /// </summary> /// <remarks> /// See details at: https://www.sautinsoft.com/products/document/help/net/developer-guide/mail-merge-table-report-with-regions-net-csharp-vb.php /// </remarks> public static void TableReportWithRegions() { // Create the Dataset and read the XML. DataSet ds = new DataSet(); ds.ReadXml(@"..\..\Orders.xml"); // Load the template document. string templatePath = @"..\..\InvoiceTemplate.docx"; DocumentCore dc = DocumentCore.Load(templatePath); // Execute the mail merge. dc.MailMerge.Execute(ds.Tables["Order"]); string resultPath = "Invoices.pdf"; // Save the output to file dc.Save(resultPath); // Open the result for demonstration purposes. System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(resultPath) { UseShellExecute = true }); } } }
Imports System Imports System.Data Imports System.IO Imports SautinSoft.Document Namespace Sample Friend Class Sample Shared Sub Main(ByVal args() As String) TableReportWithRegions() End Sub ''' <summary> ''' Generates a table report with regions using XML document as a data source. ''' </summary> ''' <remarks> ''' See details at: https://www.sautinsoft.com/products/document/help/net/developer-guide/mail-merge-table-report-with-regions-net-csharp-vb.php ''' </remarks> Public Shared Sub TableReportWithRegions() ' Create the Dataset and read the XML. Dim ds As New DataSet() ds.ReadXml("..\Orders.xml") ' Load the template document. Dim templatePath As String = "..\InvoiceTemplate.docx" Dim dc As DocumentCore = DocumentCore.Load(templatePath) ' Execute the mail merge. dc.MailMerge.Execute(ds.Tables("Order")) Dim resultPath As String = "Invoices.pdf" ' Save the output to file dc.Save(resultPath) ' Open the result for demonstration purposes. System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(resultPath) With {.UseShellExecute = True}) End Sub End Class End Namespace