FieldGreetingLine Class |
Namespace: Aspose.Words.Fields
The FieldGreetingLine type exposes the following members.
Name | Description | |
---|---|---|
![]() | FieldGreetingLine | Initializes a new instance of the FieldGreetingLine class |
Name | Description | |
---|---|---|
![]() ![]() | AlternateText |
Gets or sets the text to include in the field if the name is blank.
|
![]() ![]() | DisplayResult |
Gets the text that represents the displayed field result.
(Inherited from Field.) |
![]() ![]() | End |
Gets the node that represents the field end.
(Inherited from Field.) |
![]() ![]() | Format |
Gets a FieldFormat object that provides typed access to field's formatting.
(Inherited from Field.) |
![]() ![]() | IsDirty |
Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
(Inherited from Field.) |
![]() ![]() | IsLocked |
Gets or sets whether the field is locked (should not recalculate its result).
(Inherited from Field.) |
![]() ![]() | LanguageId |
Gets or sets the language id used to format the name.
|
![]() ![]() | LocaleId |
Gets or sets the LCID of the field.
(Inherited from Field.) |
![]() ![]() | NameFormat |
Gets or sets the format of the name included in the field.
|
![]() ![]() | Result |
Gets or sets text that is between the field separator and field end.
(Inherited from Field.) |
![]() ![]() | Separator |
Gets the node that represents the field separator. Can be null.
(Inherited from Field.) |
![]() ![]() | Start |
Gets the node that represents the start of the field.
(Inherited from Field.) |
![]() ![]() | Type |
Gets the Microsoft Word field type.
(Inherited from Field.) |
Name | Description | |
---|---|---|
![]() | Equals | (Inherited from Object.) |
![]() ![]() | GetFieldCode |
Returns text between field start and field separator (or field end if there is no separator).
Both field code and field result of child fields are included.
(Inherited from Field.) |
![]() ![]() | GetFieldCode(Boolean) |
Returns text between field start and field separator (or field end if there is no separator).
(Inherited from Field.) |
![]() ![]() | GetFieldNames |
Returns a collection of mail merge field names used by the field.
|
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() ![]() | Remove |
Removes the field from the document. Returns a node right after the field. If the field's end is the last child
of its parent node, returns its parent paragraph. If the field is already removed, returns null.
(Inherited from Field.) |
![]() | ToString | (Inherited from Object.) |
![]() ![]() | Unlink |
Performs the field unlink.
(Inherited from Field.) |
![]() ![]() | Update |
Performs the field update. Throws if the field is being updated already.
(Inherited from Field.) |
![]() ![]() | Update(Boolean) |
Performs a field update. Throws if the field is being updated already.
(Inherited from Field.) |
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a custom greeting field with document builder, and also some content FieldGreetingLine fieldGreetingLine = (FieldGreetingLine)builder.InsertField(FieldType.FieldGreetingLine, true); builder.Writeln("\n\n\tThis is your custom greeting, created programmatically using Aspose Words!"); // This array contains strings that correspond to column names in the data table that we will mail merge into our document Assert.AreEqual(0, fieldGreetingLine.GetFieldNames().Length); // To populate that array, we need to specify a format for our greeting line fieldGreetingLine.NameFormat = "<< _BEFORE_ Dear >><< _TITLE0_ >><< _LAST0_ >><< _AFTER_ ,>> "; // In this case, our greeting line's field names array now has "Courtesy Title" and "Last Name" Assert.AreEqual(2, fieldGreetingLine.GetFieldNames().Length); // This string will cover any cases where the data in the data table is incorrect by substituting the malformed name with a string fieldGreetingLine.AlternateText = "Sir or Madam"; // We can set the language ID here too fieldGreetingLine.LanguageId = "1033"; Assert.AreEqual(" GREETINGLINE \\f \"<< _BEFORE_ Dear >><< _TITLE0_ >><< _LAST0_ >><< _AFTER_ ,>> \" \\e \"Sir or Madam\" \\l 1033", fieldGreetingLine.GetFieldCode()); // Create a source table for our mail merge that has columns that our greeting line will look for 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"); // This row has an invalid value in the Courtesy Title column, so our greeting will default to the alternate text table.Rows.Add("", "No", "Name"); doc.MailMerge.Execute(table); doc.UpdateFields(); doc.Save(ArtifactsDir + "Field.GREETINGLINE.docx");