c# - 我如何知道单词列表是项目符号列表还是数字列表?

标签 c# ms-word office-interop

我正在阅读一个 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 1NormalList 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/

相关文章:

c# - MVC 4 - Html.Partial() 显示 DIV 内的 System.Namespace 文本(出现在页面上的 html 中)

c# - 如何使用 String.Replace 方法替换 html 字符串

excel - Application.Run 不会将参数传递给不同 .docm 模板中的宏,但可以在 VBA 模块中使用

c# - 创建 Excel 应用程序时出现 COM 异常 80040154

c# - System.IndexOutOfRangeException 错误 SQL SELECT 查询无法读取从我的表中选择的数据

c# - 地址之间的距离

java - 我如何使用java获取Word文档中段落的一部分的字符串的页码

c# - DocX c# 库在一行中合并表字段

powershell - 如何将 Powershell 脚本连接到已打开的文档?

c# - 使用 PowerPoint 2010 互操作的笔和记号笔