Class MailMergeExtensions
Phase 161 (WQ-0134): the merges Word's Mailings makes without touching the main document, Preview Results and Finish & Merge > Edit Individual Documents, and a recipient list read from CSV.
public static class MailMergeExtensions
- Inheritance
-
MailMergeExtensions
- Inherited Members
Remarks
Built entirely on the existing seams: FieldDiscovery locates the fields,
FieldConditional supplies Word's comparison semantics, and P14's
UpdateFields evaluates whatever the merge does not substitute itself. Nothing in
DocWright.Core changes for mail merge, and this package has no third-party
dependency -- not even System.Data.
Merged output is ordinary DOM, so it round-trips through the writer exactly as any other document does.
Methods
- Execute(WordDocument, IMergeDataReader, MailMergeOptions?)
Merges records into the document in place.
- Execute(WordDocument, IDictionary<string, object?>, MailMergeOptions?)
Merges one record into the document in place.
- GetMergeFieldNames(WordDocument)
Lists the merge fields in a document, without merging anything.
- GetMergeRegionNames(WordDocument)
Lists the merge region names a template declares, outermost first.
- 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.
- 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.
- 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.
- ValidateMergeRegions(WordDocument)
Validates a template's region markers, throwing if they are unbalanced or crossed.