FieldIndex Class
Implements the INDEX field.
Inheritance Hierarchy
SystemObject
  Aspose.Words.FieldsField
    Aspose.Words.FieldsFieldIndex

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

The FieldIndex type exposes the following members.

Constructors
  NameDescription
Public methodFieldIndex
Initializes a new instance of the FieldIndex class
Properties
  NameDescription
Public propertyCode exampleBookmarkName
Gets or sets the name of the bookmark that marks the portion of the document used to build the index.
Public propertyCode exampleCrossReferenceSeparator
Gets or sets the character sequence that is used to separate cross references and other entries.
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 used to build the index.
Public propertyCode exampleFormat
Gets a FieldFormat object that provides typed access to field's formatting.
(Inherited from Field.)
Public propertyCode exampleHasPageNumberSeparator
Gets a value indicating whether a page number separator is overridden through the field's code.
Public propertyCode exampleHasSequenceName
Gets a value indicating whether a sequence should be used while the field's result building.
Public propertyCode exampleHeading
Gets or sets a heading that appears at the start of each set of entries for any given letter.
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 exampleIsLocked
Gets or sets whether the field is locked (should not recalculate its result).
(Inherited from Field.)
Public propertyCode exampleLanguageId
Gets or sets the language ID used to generate the index.
Public propertyCode exampleLetterRange
Gets or sets a range of letters to which limit the index.
Public propertyCode exampleLocaleId
Gets or sets the LCID of the field.
(Inherited from Field.)
Public propertyCode exampleNumberOfColumns
Gets or sets the number of columns per page used when building the index.
Public propertyCode examplePageNumberListSeparator
Gets or sets the character sequence that is used to separate two page numbers in a page number list.
Public propertyCode examplePageNumberSeparator
Gets or sets the character sequence that is used to separate an index entry and its page number.
Public propertyCode examplePageRangeSeparator
Gets or sets the character sequence that is used to separate the start and end of a page range.
Public propertyCode exampleResult
Gets or sets text that is between the field separator and field end.
(Inherited from Field.)
Public propertyCode exampleRunSubentriesOnSameLine
Gets or sets whether run subentries into the same line as the main entry.
Public propertyCode exampleSeparator
Gets the node that represents the field separator. Can be null.
(Inherited from Field.)
Public propertyCode exampleSequenceName
Gets or sets the name of a sequence whose number is included with the page number.
Public propertyCode exampleSequenceSeparator
Gets or sets the character sequence that is used to separate sequence numbers and page numbers.
Public propertyCode exampleStart
Gets the node that represents the start of the field.
(Inherited from Field.)
Public propertyCode exampleType
Gets the Microsoft Word field type.
(Inherited from Field.)
Public propertyCode exampleUseYomi
Gets or sets whether to enable the use of yomi text for index entries.
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
Builds an index using the index entries specified by XE fields, and inserts that index at this place in the document.
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