我正在阅读一个 word 文档(将其转换为 HTML)并想知道每个段落的类型(至少我认为我想这样做)。
我的代码是这样的
Application application = new Application();
var doc = application.Documents.Open("D:\\myDoc.docx");
for (int i = 0; i < doc.Paragraphs.Count; i++)
{
Console.WriteLine($"{doc.Paragraphs[i + 1].Range.ParagraphStyle.NameLocal}");
}
例如,这会输出 Header 1、Normal 和 List Paragraph。所以我的问题。我看不出 List Paragraph 是项目符号列表还是数字列表。问题,我怎么知道列表是什么类型?
最佳答案
使用 Range.ListFormat.ListType
可以有以下值:
// Summary:
// Specifies a type of list.
public enum WdListType
{
// Summary:
// List with no bullets, numbering, or outlining.
wdListNoNumbering = 0,
//
// Summary:
// ListNum fields that can be used in the body of a paragraph.
wdListListNumOnly = 1,
//
// Summary:
// Bulleted list.
wdListBullet = 2,
//
// Summary:
// Simple numeric list.
wdListSimpleNumbering = 3,
//
// Summary:
// Outlined list.
wdListOutlineNumbering = 4,
//
// Summary:
// Mixed numeric list.
wdListMixedNumbering = 5,
//
// Summary:
// Picture bulleted list.
wdListPictureBullet = 6,
}
关于c# - 我如何知道单词列表是项目符号列表还是数字列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35460990/