Method MergeToNewDocument
MergeToNewDocument(WordDocument, IMergeDataReader, MailMergeOptions?)
Merges every record into a copy of the template, as Word's Edit Individual Documents does: one copy per record,
each in its own section, every merge field replaced by its value, the main document's mail-merge settings
(w:mailMerge) not carried. The template is not changed.
public static (WordDocument Document, MergeResult Result) MergeToNewDocument(this WordDocument template, IMergeDataReader data, MailMergeOptions? options = null)
Parameters
templateWordDocumentThe main document.
dataIMergeDataReaderThe records.
optionsMailMergeOptionsThe options (their record separator is Word's section break here), or null for the defaults.
Returns
- (WordDocument Document, MergeResult Result)
The merged document and what the merge did.
Exceptions
- ArgumentNullException
templateordatais null.- MergeTemplateException
A region marker is unbalanced or crossed.