officefileapi-devexpress-dot-spreadsheet-dot-iworkbook-c672c875.md
Performs the mail merge and returns the collection of resulting workbooks.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
IList<IWorkbook> GenerateMailMergeDocuments()
Function GenerateMailMergeDocuments As IList(Of IWorkbook)
| Type | Description |
|---|---|
| IList<IWorkbook> |
An IList object that contains workbooks generated after the mail merge is preformed.
|
The manner of generating the mail merge result depends on the used mail merge mode.
| Mail Merge Mode | Mail Merge Result |
|---|---|
| Multiple Documents | Each data record is merged into a separate workbook. So, the mail merge results in as many workbooks as there are records in the specified data member (IWorkbook.MailMergeDataMember) of the bound data source (IWorkbook.MailMergeDataSource). |
| Multiple Worksheets | Each data record is merged into a separate worksheet in a single workbook. So, the mail merge results in a single workbook. |
| Single Worksheet | All data records are inserted one after the other into a single worksheet. So, the mail merge results in a single workbook. |
When performing the mail merge, you can sort, group and filter data to appear in resulting documents.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GenerateMailMergeDocuments() method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-spreadsheet-mail-merge/CS/DXApplication1/Form1.cs#L30
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
IList<IWorkbook> resultWorkbooks = spreadsheetControl1.Document.GenerateMailMergeDocuments();
int index = 0;
winforms-spreadsheet-mail-merge/VB/DXApplication1/Form1.vb#L30
Private Sub barButtonItem1_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barButtonItem1.ItemClick
Dim resultWorkbooks As IList(Of IWorkbook) = spreadsheetControl1.Document.GenerateMailMergeDocuments()
Dim index As Integer = 0
See Also
Mail Merge in WinForms Spreadsheet Control