Change Theme Settings
Change Theme Settings
Themes
 
Show All Themes
v
...v

Mail Merging

Choose mail merge mode:
  • Undo

    Undo
    po
  • Clipboard

    Clipboard
    po
  • v
    v
    popopopo
    Font

    Font
    po
  • Alignment

    Alignment
    po
  • po
    dialogboxlauncherNumber

    Number
    po
  • Cells

    Cells
    po
  • Editing

    Editing
    po
  • Styles

    Styles
    po
  • dialogboxlauncherPage Setup

    Page Setuppo
  • dialogboxlauncherPrint

    Print
    po
  • Document Views

    Document Viewspo
  • Show

    Show
    po
  • View

    View
    po
  • Window

    Window
    po
  • Properties

    Properties
    po
  • Tools

    Tools
    po
  • Table Style Options

    Table Style Optionspo
  • Table Style Options

    Table Style Optionspo
  • Layout

    Layout
    po
  • PivotTable Style Options

    PivotTable Style Optionspo
 

The Mail Merge functionality provided by the DevExpress ASP.NET Spreadsheet (ASPxSpreadsheet) enables you to automatically generate a set of documents based on a common template and fill each document with unique data values retrieved from a data source. This feature can be useful for a variety of business requirements, such as personalizing letters, and composing catalogs and reports.

To perform a mail merge, you need a template and a data source.

A template is a spreadsheet document that contains static information (which is the same for all resulting documents) and mail merge fields. A mail merge field is a placeholder in which a value from the specified data source field will appear in a merged document. To insert fields into template cells, use the following special functions in cell formulas: FIELD and FIELDPICTURE.

A data source contains data that will be merged into fields in a template to create merged documents.

To bind a template to a data source, use the IWorkbook.MailMergeDataSource and IWorkbook.MailMergeDataMember properties of the template workbook.

Within a template, you can choose a mail merge mode specifying how the result of the mail merge should be generated. The mail merge mode is specified programmatically at the template workbook level, by setting a specific defined name ("MAILMERGEMODE") to a particular string constant ("Worksheets" or "OneWorksheet").

  • "OneWorksheet" (Single Sheet) - Merged ranges for all data source records are inserted one after another (vertically or horizontally, depending on the document orientation) into a single worksheet. This mode is used by default.
  • "Worksheets" (Multiple Sheets) - The merged range for each data source record is inserted into a separate worksheet in a single workbook.

Note that by default, the "MAILMERGEMODE" defined name does not exist in a template workbook and the "Single Sheet" mode is used.

To finalize the mail merge process, use the IWorkbook.GenerateMailMergeDocuments method of the template workbook. This method returns a collection of resulting workbooks containing the merged documents (if the "Single Sheet" or "Multiple Sheets" mail merge mode is used, the collection contains a single workbook).

In this demo, we illustrate the merging of images along with personal information for contacts from the Northwind database's Employees table.

Collapse/Expand
Local Copy of this Demo
To inspect the source code for this demo on your machine, you must first install our components via the DevExpress Component Installer.
You can open a local copy of this online demo directly from this webpage (if using v20.2.8, 21.1.4 or higher).
Open CS Solution
Open VB Solution
The source code files for this demo are installed (by default) in the following directories:
\Users\Public\Documents\DevExpress Demos XX.X\Components\ASP.NET\CS\ASPxSpreadsheetDemos
\Users\Public\Documents\DevExpress Demos XX.X\Components\ASP.NET\VB\ASPxSpreadsheetDemos