【问题标题】:c# Restart numbering list in word with Interop or Asposec#使用Interop或Aspose重新启动word中的编号列表
【发布时间】:2015-03-03 08:30:57
【问题描述】:

我在 Interop 中遇到了 ApplyListTemplate 的问题, 此方法即使对于未编号的段落也会重新编号

我使用了这个代码:

            this.Application.ActiveDocument.Range().ListFormat.ApplyListTemplateWithLevel(
            ListTemplate: this.Application.ActiveDocument.ListTemplates[listNumber],
            ContinuePreviousList: false,
            ApplyTo: Microsoft.Office.Interop.Word.WdListApplyTo.wdListApplyToWholeList,
            DefaultListBehavior: Microsoft.Office.Interop.Word.WdDefaultListBehavior.wdWord10ListBehavior);

问题是一个没有应用列表编号的段落返回 1——而它实际上应该什么也不返回或 0、或 10、或 9999,或者表明它没有列表级别的东西——但肯定不是 1。这是一个错误。

此外,如果您有解决方案,我有一个 Aspose 许可证。

【问题讨论】:

标签: c# ms-word interop aspose


【解决方案1】:

我找到了解决问题的方法。

 int listNumber = 1;
 foreach (Paragraph p in this.Application.ActiveDocument.Paragraphs)
        {
            if (p.Range.ListFormat.ListType != WdListType.wdListNoNumbering)
            {
                p.Range.ListFormat.ApplyListTemplate(
                    ListTemplate: this.Application.ActiveDocument.ListTemplates[listNumber],
                    ContinuePreviousList: true,
                    ApplyTo: Microsoft.Office.Interop.Word.WdListApplyTo.wdListApplyToWholeList,
                    DefaultListBehavior: Microsoft.Office.Interop.Word.WdDefaultListBehavior.wdWord10ListBehavior);
            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-21
    • 1970-01-01
    • 2011-05-09
    • 2017-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多