MergeObjects Method
- Namespace
TXTextControl.DocumentServer
- Package
TXTextControl.asTextControl. WPF. SDK TXDocumentServer.from the private NuGet feed or Text Control Offline Packagesdll
Description
Merges a collection of type System.Collections.IEnumerable containing objects of any type or instances of type System.Collections.Generic.Dictionary with string keys into the loaded document template.
Syntax
MergeObjects(IEnumerable, bool)
Interprets all public properties of the objects or the key names of the dictionaries in the collection as possible table columns and / or child tables. The type of the first object (or the key names and types of the first dictionary) in the collection is analyzed via .NET reflection and used as the basis of the assumed table structure. (In case of the collection containing objects of different types, the merge process is successful nevertheless, but some fields will be empty.) Properties of simple data types (e. g. string, int, enum) are converted to text using the ToString method. The textual representation of enum values can be specified using the System.ComponentModel.DescriptionAttribute. (For example: enum FoodCategory { [Description("Grains / Cereals")] Grains_Cereals, ... }.) The name by which Properties are mapped to field names can be adjusted using the System.ComponentModel.DisplayNameAttribute. (For example: [DisplayName("Name")] public string ProductName { get; set; }.) Complex properties which are themselves of type System.Collections.IEnumerable are interpreted as child Tables and used for merging merge blocks and nested merge blocks. This way data relations can be represented. Properties of a type itself having public properties are either interpreted as a simple table column (the merged text then is determined using the ToString() method) or they are treated as if they were a child table containing only one data row with the properties being the table columns. The second parameter specifies whether the single documents should be merged into one document or split into separate documents. The supported format of the merge fields can be found in the ASP.NET User's Guide.
public void MergeObjects(IEnumerable mergeData, bool append);Public Sub MergeObjects(mergeData As IEnumerable, append As Boolean)| Parameter | Description |
|---|---|
| mergeData | Specifies a |
| append | Specifies whether the single documents should be merged into one document or split into separate documents. |
MergeObjects(IEnumerable)
Does the same as MergeObjects with the parameter “append” set to true.
public void MergeObjects(IEnumerable mergeData);Public Sub MergeObjects(mergeData As IEnumerable)| Parameter | Description |
|---|---|
| mergeData | Specifies a |
Examples
The following example uses Merge Objects in a focused Mail Merge workflow. The created object is then available to the surrounding document workflow.
mailMerge.MergeObjects(new UserDefinedPropertyDictionary(), true);
Console.WriteLine("Mail Merge is ready for use.");mailMerge.MergeObjects(New UserDefinedPropertyDictionary(), True)
Console.WriteLine("Mail Merge is ready for use.")