FieldXEEntryType Property

Gets or sets an index entry type.

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

Syntax

public string EntryType { get; set; }

Property Value

Type: String

Examples

Shows how to omit entries while populating an INDEX field with entries from XE fields.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create an INDEX field which will display the page locations of XE fields in the document body
FieldIndex index = (FieldIndex)builder.InsertField(FieldType.FieldIndex, true);

// Set these attributes so that an XE field shows up in the INDEX field's result
// only if it is within the bounds of a bookmark named "MainBookmark", and is of type "A"
index.BookmarkName = "MainBookmark";
index.EntryType = "A";

Assert.AreEqual(" INDEX  \\b MainBookmark \\f A", index.GetFieldCode());

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

// Start the bookmark that will contain all eligible XE entries
builder.StartBookmark("MainBookmark");

// This entry will be picked up by the INDEX field because it is inside the bookmark
// and its type matches the INDEX field's type
// Note that even though the type is a string, it is defined by only the first character
FieldXE indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "Index entry 1";
indexEntry.EntryType = "A";

Assert.AreEqual(" XE  \"Index entry 1\" \\f A", indexEntry.GetFieldCode());

// Insert an XE field that will not appear in the INDEX field because it is of the wrong type
builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "Index entry 2";
indexEntry.EntryType = "B";

// End the bookmark and insert an XE field afterwards
// It is of the same type as the INDEX field, but will not appear since it is outside of the bookmark
// Note that the INDEX field itself does not have to be within its bookmark
builder.EndBookmark("MainBookmark");
builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "Index entry 3";
indexEntry.EntryType = "A";

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.INDEX.XE.Filtering.docx");

See Also