FieldXEYomi Property

Gets or sets the yomi (first phonetic character for sorting indexes) for the index entry

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

Syntax

public string Yomi { get; set; }

Property Value

Type: String

Examples

Shows how to sort INDEX field entries phonetically.
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 the INDEX table to sort entries phonetically using Hiragana
index.UseYomi = doSortEntriesUsingYomi;

if (doSortEntriesUsingYomi)
    Assert.AreEqual(" INDEX  \\y", index.GetFieldCode());
else
    Assert.AreEqual(" INDEX ", index.GetFieldCode());

// Insert 4 XE fields, which would show up as entries in the INDEX field's table of contents,
// sorted in lexicographic order on their "Text" attribute
builder.InsertBreak(BreakType.PageBreak);
FieldXE indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "愛子";

// The "Text" attrubute may contain a word's spelling in Kanji, whose pronounciation may be ambiguous,
// while a "Yomi" version of the word will be spelled exactly how it is pronounced using Hiragana
// If our INDEX field is set to use Yomi, then we can sort phonetically using the "Yomi" attribute values instead of the "Text" attribute
indexEntry.Yomi = "あ";

Assert.AreEqual(" XE  愛子 \\y あ", indexEntry.GetFieldCode());

builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "明美";
indexEntry.Yomi = "あ";

builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "恵美";
indexEntry.Yomi = "え";

builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "愛美";
indexEntry.Yomi = "え";

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

See Also