FieldMergeFieldIsMapped Property

Gets or sets whether this field is a mapped field.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.9.0

Syntax

public bool IsMapped { get; set; }

Property Value

Type: Boolean

Examples

Shows how to use MERGEFIELD fields to perform a mail merge.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create data source for our merge fields
DataTable table = new DataTable("Employees");
table.Columns.Add("Courtesy Title");
table.Columns.Add("First Name");
table.Columns.Add("Last Name");
table.Rows.Add("Mr.", "John", "Doe");
table.Rows.Add("Mrs.", "Jane", "Cardholder");

// Insert a merge field that corresponds to one of our columns and put text before and after it
FieldMergeField fieldMergeField = (FieldMergeField)builder.InsertField(FieldType.FieldMergeField, true);
fieldMergeField.FieldName = "Courtesy Title";
fieldMergeField.IsMapped = true;
fieldMergeField.IsVerticalFormatting = false;
fieldMergeField.TextBefore = "Dear ";
fieldMergeField.TextAfter = " ";

Assert.AreEqual(" MERGEFIELD  \"Courtesy Title\" \\m \\b \"Dear \" \\f \" \"", fieldMergeField.GetFieldCode());

// Insert another merge field for another column
// We do not need to use every column to perform a mail merge
fieldMergeField = (FieldMergeField)builder.InsertField(FieldType.FieldMergeField, true);
fieldMergeField.FieldName = "Last Name";
fieldMergeField.TextAfter = ":";

doc.UpdateFields();
doc.MailMerge.Execute(table);
doc.Save(ArtifactsDir + "Field.MERGEFIELD.docx");

See Also