ApiExamples.ExMailMerge.ExecuteWithRegionsDataSet C# (CSharp) Method

ExecuteWithRegionsDataSet() private method

private ExecuteWithRegionsDataSet ( ) : void
return void
        public void ExecuteWithRegionsDataSet()
        {
            //ExStart
            //ExFor:MailMerge.ExecuteWithRegions(DataSet)
            //ExSummary:Executes a mail merge with repeatable regions from an ADO.NET DataSet.
            // Open the document. 
            // For a mail merge with repeatable regions, the document should have mail merge regions 
            // in the document designated with MERGEFIELD TableStart:MyTableName and TableEnd:MyTableName.
            Document doc = new Document(MyDir + "MailMerge.ExecuteWithRegions.doc");

            int orderId = 10444;

            // Populate tables and add them to the dataset.
            // For a mail merge with repeatable regions, DataTable.TableName should be 
            // set to match the name of the region defined in the document.
            DataSet dataSet = new DataSet();

            DataTable orderTable = GetTestOrder(orderId);
            dataSet.Tables.Add(orderTable);

            DataTable orderDetailsTable = GetTestOrderDetails(orderId);
            dataSet.Tables.Add(orderDetailsTable);

            // This looks through all mail merge regions inside the document and for each
            // region tries to find a DataTable with a matching name inside the DataSet.
            // If a table is found, its content is merged into the mail merge region in the document.
            doc.MailMerge.ExecuteWithRegions(dataSet);

            doc.Save(MyDir + @"\Artifacts\MailMerge.ExecuteWithRegionsDataSet.doc");
            //ExEnd
        }