GetEffectiveValue
ListLevel.GetEffectiveValue method
报告的字符串表示形式ListLevel
列表项的指定index 的对象。参数指定NumberStyle
以及可选格式 string 时使用Custom已指定。
public static string GetEffectiveValue(int index, NumberStyle numberStyle,
string customNumberStyleFormat)
范围 | 类型 | 描述 |
---|---|---|
index | Int32 | 列表项的索引(必须在 1 到 32767 范围内)。 |
numberStyle | NumberStyle | 的NumberStyle 的ListLevel 对象. |
customNumberStyleFormat | String | 时使用的可选格式字符串Custom被指定(例如“a, ç, ĝ, …”)。 在其他情况下,该参数必须是无效的 或为空。 |
返回值
的字符串表示形式ListLevel
对象,由numberStyle参数and customNumberStyleFormat参数,在列表项中由index参数.
例外
例外 | (健康)状况 |
---|---|
ArgumentException | customNumberStyleFormat是无效的 或空时numberStyle是定制的。-或- customNumberStyleFormat不是无效的 或空时numberStyle是非自定义的。-或- customNumberStyleFormat无效。 |
ArgumentOutOfRangeException | 索引超出范围。 |
例子
演示如何获取具有自定义数字样式的列表的格式。
Document doc = new Document(MyDir + "List with leading zero.docx");
ListLevel listLevel = doc.FirstSection.Body.Paragraphs[0].ListFormat.ListLevel;
string customNumberStyleFormat = string.Empty;
if (listLevel.NumberStyle == NumberStyle.Custom)
customNumberStyleFormat = listLevel.CustomNumberStyleFormat;
Assert.AreEqual("001, 002, 003, ...", customNumberStyleFormat);
// 我们可以获取列表项的指定索引的值。
Assert.AreEqual("iv", ListLevel.GetEffectiveValue(4, NumberStyle.LowercaseRoman, null));
Assert.AreEqual("005", ListLevel.GetEffectiveValue(5, NumberStyle.Custom, customNumberStyleFormat));
也可以看看
- enum NumberStyle
- class ListLevel
- 命名空间 Aspose.Words.Lists
- 部件 Aspose.Words