CustomNumberStyleFormat
ListLevel.CustomNumberStyleFormat property
获取或设置此列表级别的自定义数字样式格式。例如:“a、ç、ĝ、…”。
public string CustomNumberStyleFormat { get; set; }
例子
展示如何设置客户编号样式格式。
Document doc = new Document(MyDir + "List with leading zero.docx");
doc.UpdateListLabels();
ParagraphCollection paras = doc.FirstSection.Body.Paragraphs;
Assert.AreEqual("001.", paras[0].ListLabel.LabelString);
Assert.AreEqual("0001.", paras[1].ListLabel.LabelString);
Assert.AreEqual("0002.", paras[2].ListLabel.LabelString);
paras[1].ListFormat.ListLevel.CustomNumberStyleFormat = "001, 002, 003, ...";
doc.UpdateListLabels();
Assert.AreEqual("001.", paras[0].ListLabel.LabelString);
Assert.AreEqual("001.", paras[1].ListLabel.LabelString);
Assert.AreEqual("002.", paras[2].ListLabel.LabelString);
展示如何获取具有自定义数字样式的列表格式。
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));
也可以看看
- class ListLevel
- 命名空间 Aspose.Words.Lists
- 部件 Aspose.Words