ActiveReports 18 .NET Edition
Report Authors: Designer Components / Design Reports / Design Page/RDLX Reports / Tutorials: Report Controls in Page/RDLX Reports / Mail Merge with FormattedText Control
In This Topic
    Mail Merge with FormattedText Control
    In This Topic

    Let's create a mail merge report that uses the FormattedText control to display the discount percent, start date, and end date for different sales promotions. We will use the List data region to repeat the data in the FormattedText control for each unique promotion key in the dataset.

    The final report will look as shown.

    Mail Merge Report with FormattedText

    Create a Report

    In the ActiveReports Designer, create a new RDLX report.

    If you are creating a new report in the Visual Studio Integrated Designer, see Quick Start.

    Bind Report to Data

    As you create a new report, you can configure the report data connection in the Report Wizard. You can also access the Report Data Source dialog by right-clicking the Data Sources node in the Report Explorer and then selecting the Add Data Source option. See JSON for details.

    1. On the Choose Data Source Type screen of the wizard, select JSON and click Next.
    2. To specify JSON File Path, click the Browse button and navigate to the desired file on your system. This report uses the 'DimPromotions.json' sample data source that can be downloaded from the following URL:
          https://demodata.mescius.io/contoso/odata/v1/DimPromotions   
    3. Click the Next option and configure the dataset by adding a valid query. Enter PromotionDataset into the Name field and select the node from the data tree in the Path section to generate the path. The resulting query is displayed in the Query field.
    4. Click Next to proceed to the final screen of the Report Wizard.
    5. Review the summary of the report and click Finish to successfully add the report with the JSON data source.

    Design Report

    1. Drag and drop the List data region on the design area.
    2. With the List data region selected, set the DataSetName as the name of the dataset, 'PromotionDataset'.
    3. Go to the Property dialog and set the Detail Grouping to expression  =Fields!PromotionKey.Value
    4. Now, drag and drop the FormattedText control on the List data region. Check from the Report Explorer that the FormattedText is nested within the List data region.
    5. To encode mail merge fields, go to the MailMergeFields property and click ellipses next to (Collections).
    6. In the Mail Merge dialog, check the Encode Mail Merge Fields option and add the mail merge fields with the following 'Field' and 'Value' pairs:
      • Field1: PromotionName, Value: =Fields!PromotionName.Value
      • Field2: DiscountPercent, Value: =Fields!DiscountPercent.Value * 100
      • Field3: StartDate, Value: =Format(Fields!StartDate.Value, "dd-MM-yyyy")
      • Field4: EndDate, Value: =Format(Fields!EndDate.Value, "dd-MM-yyyy")
    7. Set the control's Html property to the following text.
       
      HTML
      Copy Code
      <!DOCTYPE html>
       
      <html lang="en">
            
         <head>           
            <title>Mail Merge Report</title>          
         </head>
                 
         <body bgcolor="#E23940">  
            <h2 style="color:white; text-align:center;font-family:Segoe UI;"><% PromotionName /%></h2>                  
            <h1 style="color:white;text-align:center;font-size:50px; font-family:Segoe UI;">GET<br><big><% DiscountPercent /%>%</big> OFF</h1>                  
            <h2 style="background-color:white;color:#E23940;text-align:center;font-size=35px;font-family:Segoe UI;font-weight:bold">LIMITED PERIOD OFFER</h2>                  
            <h4 style="color:white;text-align:center;font-size=35px;font-family:Segoe UI;">* Valid from <%StartDate /%> to <% EndDate /%> in all our stores. Cannot be combined with any other offers. No cash value. Northwind Traders can cancel promotion at any time.</h4>
            <img align="center" src="https://demodata.mescius.io/images/NorthWind_large.png" style="width:1.5inin;height:2in" />              
         </body>
         
      </html>
      
    8. Improve the appearance of the controls and preview the report.
    See Also