Table of Contents

Method PreviewRecord

Namespace
DocWright.MailMerge
Assembly
DocWright.MailMerge.dll

PreviewRecord(WordDocument, IReadOnlyDictionary<string, object?>, MailMergeOptions?)

Merges one record into a copy of the template, as Word's Preview Results shows it. The template is not changed.

public static WordDocument PreviewRecord(this WordDocument template, IReadOnlyDictionary<string, object?> record, MailMergeOptions? options = null)

Parameters

template WordDocument

The main document.

record IReadOnlyDictionary<string, object>

The record.

options MailMergeOptions

The options, or null for the defaults.

Returns

WordDocument

The previewed document.

Exceptions

ArgumentNullException

template or record is null.

MergeTemplateException

A region marker is unbalanced or crossed.

PreviewRecord(WordDocument, IReadOnlyDictionary<string, object?>, int, MailMergeOptions?)

Merges one record into a copy of the template as Word's Preview Results shows it, numbered as the recordNumberth record (Phase 167): «Merge Record #» and «Merge Sequence #» show the number its copy has in MergeToNewDocument(WordDocument, IMergeDataReader, MailMergeOptions?). The template is not changed.

public static WordDocument PreviewRecord(this WordDocument template, IReadOnlyDictionary<string, object?> record, int recordNumber, MailMergeOptions? options = null)

Parameters

template WordDocument

The main document.

record IReadOnlyDictionary<string, object>

The record.

recordNumber int

The record's number in the merge, from 1.

options MailMergeOptions

The options, or null for the defaults.

Returns

WordDocument

The previewed document.

Exceptions

ArgumentNullException

template or record is null.

ArgumentOutOfRangeException

recordNumber is less than 1.

MergeTemplateException

A region marker is unbalanced or crossed.