FieldXE Class
Implements the XE field.
Inheritance Hierarchy
SystemObject
  Aspose.Words.FieldsField
    Aspose.Words.FieldsFieldXE

Namespace: Aspose.Words.Fields
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public class FieldXE : Field

The FieldXE type exposes the following members.

Constructors
  NameDescription
Public methodFieldXE
Initializes a new instance of the FieldXE class
Properties
  NameDescription
Public propertyCode exampleDisplayResult
Gets the text that represents the displayed field result.
(Inherited from Field.)
Public propertyCode exampleEnd
Gets the node that represents the field end.
(Inherited from Field.)
Public propertyCode exampleEntryType
Gets or sets an index entry type.
Public propertyCode exampleFormat
Gets a FieldFormat object that provides typed access to field's formatting.
(Inherited from Field.)
Public propertyCode exampleHasPageRangeBookmarkName
Gets a value indicating whether a page range bookmark name is provided through the field's code.
Public propertyCode exampleIsBold
Gets or sets whether to apply bold formatting to the entry's page number.
Public propertyCode exampleIsDirty
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.)
Public propertyCode exampleIsItalic
Gets or sets whether to apply italic formatting to the entry's page number.
Public propertyCode exampleIsLocked
Gets or sets whether the field is locked (should not recalculate its result).
(Inherited from Field.)
Public propertyCode exampleLocaleId
Gets or sets the LCID of the field.
(Inherited from Field.)
Public propertyCode examplePageNumberReplacement
Gets or sets text used in place of a page number.
Public propertyCode examplePageRangeBookmarkName
Gets or sets the name of the bookmark that marks a range of pages that is inserted as the entry's page number.
Public propertyCode exampleResult
Gets or sets text that is between the field separator and field end.
(Inherited from Field.)
Public propertyCode exampleSeparator
Gets the node that represents the field separator. Can be null.
(Inherited from Field.)
Public propertyCode exampleStart
Gets the node that represents the start of the field.
(Inherited from Field.)
Public propertyCode exampleText
Gets or sets the text of the entry.
Public propertyCode exampleType
Gets the Microsoft Word field type.
(Inherited from Field.)
Public propertyCode exampleYomi
Gets or sets the yomi (first phonetic character for sorting indexes) for the index entry
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetFieldCode
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.)
Public methodCode exampleGetFieldCode(Boolean)
Returns text between field start and field separator (or field end if there is no separator).
(Inherited from Field.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodNeedStoreOldResultNodes (Inherited from Field.)
Public methodCode exampleRemove
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.)
Public methodToString (Inherited from Object.)
Public methodCode exampleUnlink
Performs the field unlink.
(Inherited from Field.)
Public methodCode exampleUpdate
Performs the field update. Throws if the field is being updated already.
(Inherited from Field.)
Public methodCode exampleUpdate(Boolean)
Performs a field update. Throws if the field is being updated already.
(Inherited from Field.)
Remarks
Defines the text and page number for an index entry, which is used by an INDEX field.
Examples
Shows how to populate an index field with index entries.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create an index field which will contain all the index entries
FieldIndex index = (FieldIndex)builder.InsertField(FieldType.FieldIndex, true);

// Bookmark that will encompass a section that we want to index
string mainBookmarkName = "MainBookmark";
builder.StartBookmark(mainBookmarkName);
index.BookmarkName = mainBookmarkName;
index.CrossReferenceSeparator = ":";
index.Heading = ">";
index.LanguageId = "1033";
index.LetterRange = "a-j";
index.NumberOfColumns = "2";
index.PageNumberListSeparator = "|";
index.PageNumberSeparator = "|";
index.PageRangeSeparator = "/";
index.UseYomi = true;
index.RunSubentriesOnSameLine = false;
index.SequenceName = "Chapter";
index.SequenceSeparator = ":";
Assert.IsTrue(index.HasPageNumberSeparator);
Assert.IsTrue(index.HasSequenceName);

// Our index will take up page 1
builder.InsertBreak(BreakType.PageBreak);

// Use a document builder to insert an index entry
// Index entries are not added to the index manually, it will find them on its own
FieldXE indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "Index entry 1";
indexEntry.EntryType = "Type1";
indexEntry.IsBold = true;
indexEntry.IsItalic = true;
Assert.AreEqual(false, indexEntry.HasPageRangeBookmarkName);

// We can insert a bookmark and have the index field point to it
string subBookmarkName = "MyBookmark";
builder.StartBookmark(subBookmarkName);
builder.Writeln("Bookmark text contents.");
builder.EndBookmark(subBookmarkName);

// Put the bookmark and index entry field on different pages
// Our index will use the page that the bookmark is on, not that of the index entry field, as the page number
builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "Index entry 2";
indexEntry.EntryType = "Type1";
indexEntry.PageRangeBookmarkName = subBookmarkName;
Assert.AreEqual(true, indexEntry.HasPageRangeBookmarkName);

// We can use the PageNumberReplacement property to point to any page we want, even one that may not exist
builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "Index entry 3";
indexEntry.EntryType = "Type1";
indexEntry.PageNumberReplacement = "999";

// If we are using an East Asian language, we can sort entries phonetically (using Furigana) instead of alphabetically
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "漢字";
indexEntry.EntryType = "Type1";

// The Yomi field will contain the character looked up for sorting
indexEntry.Yomi = "か";

// If we are sorting phonetically, we need to notify the index
index.UseYomi = true;

// For all our entry fields, we set the entry type to "Type1"
// Our field index will not list those entries unless we set its entry type to that of the entries
index.EntryType = "Type1";

builder.EndBookmark(mainBookmarkName);

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.XE.docx");
See Also