Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
  • The page you are viewing does not exist in the .NET Standard 2.0+ platform documentation. This link will take you to the parent topic of the current section.

SnapDocumentServer Class

A non-visual reporting engine providing all the functionality of Snap.

Namespace: DevExpress.Snap

Assembly: DevExpress.Docs.v19.1.dll


public class SnapDocumentServer :


The following code uses the Snap Report API to generate a mail-merge report in the context of the DevExpress Office File API.

It is a console application that creates a document and then exports it to an RTF file.

To use the SnapDocumentServer, the project requires references to the following assemblies:

  • DevExpress.Data.v19.1.dll
  • DevExpress.Docs.v19.1.dll
  • DevExpress.Office.v19.1.Core.dll
  • DevExpress.RichEdit.v19.1.Core.dll
  • DevExpress.Snap.v19.1.Core.dll

To perform mail merge, the application requires a template - a file in the native .SNX format which contains the document layout, specific fields and data source information. The template file must be created beforehand using the Snap Design Surface. For an example of template creation, review the Lesson 3 - Create a Mail Merge Report.

The code handles the SnapDocumentServer.SnapMailMergeRecordStarted and SnapDocumentServer.SnapMailMergeRecordFinished events to make adjustments to the merged document created for the particular data record.

The server loads a mail merge template using the RichEditDocumentServer.LoadDocument method. Subsequently, the code creates the SnapMailMergeExportOptions object and assigns the data source by specifying the IDataSourceContainerOptions.DataSource property. The mail merge operation is performed by calling the SnapDocumentServer.SnapMailMerge method.

SnapDocumentServer server = new SnapDocumentServer();

server.SnapMailMergeRecordStarted += server_SnapMailMergeRecordStarted;
server.SnapMailMergeRecordFinished += server_SnapMailMergeRecordFinished;

object dataSource = CreateDataSource();

SnapMailMergeExportOptions options = server.Document.CreateSnapMailMergeExportOptions();
options.DataSource = dataSource;
Console.Write("Performing mail merge... ");
server.SnapMailMerge(options, outputFileName, DocumentFormat.Rtf);

The following code snippets (auto-collected from DevExpress Examples) contain references to the SnapDocumentServer class.


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.


See Also