Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用NetOffice API获取页面中的所有标题(而不是标题)?_C#_Netoffice - Fatal编程技术网

C# 如何使用NetOffice API获取页面中的所有标题(而不是标题)?

C# 如何使用NetOffice API获取页面中的所有标题(而不是标题)?,c#,netoffice,C#,Netoffice,如何使用NetOffice API获取页面中的所有标题(而不是标题) 文档很少,我很难在页面/文档中获取标题文本。有人能帮忙吗?Word对象模型在页面中没有任何标题。所以很明显,Netoffice也不能做任何事情(它只是那些对象模型的包装器)。有目录和图表 您必须遍历样式,查看标题样式是否匹配。默认情况下,Word 2010中标题的样式为“标题1”,因此请遍历段落并检查其样式 使用VSTO的示例-将其更改为NetOffice Range rangeToInspect = // Range tha

如何使用NetOffice API获取页面中的所有标题(而不是标题)


文档很少,我很难在页面/文档中获取标题文本。有人能帮忙吗?

Word对象模型在页面中没有任何标题。所以很明显,Netoffice也不能做任何事情(它只是那些对象模型的包装器)。有目录和图表

您必须遍历样式,查看标题样式是否匹配。默认情况下,Word 2010中标题的样式为“标题1”,因此请遍历段落并检查其样式

使用VSTO的示例-将其更改为NetOffice

Range rangeToInspect = // Range that you need to inspect
Style refStyles;
        foreach (Paragraph para in rangeToInspect.Paragraphs)
        {
            refStyles = para.get_Style();
            if (refStyles != null)
            {
                if (refStyles.NameLocal.Contains("Heading 1", StringComparison.OrdinalIgnoreCase))
                {
                    //Do the stuff here with Heading
                }
            }
        }

Word对象模型无法获取页面中的标题。所以很明显,Netoffice也不能做任何事情(它只是那些对象模型的包装器)。有目录和图表

您必须遍历样式,查看标题样式是否匹配。默认情况下,Word 2010中标题的样式为“标题1”,因此请遍历段落并检查其样式

使用VSTO的示例-将其更改为NetOffice

Range rangeToInspect = // Range that you need to inspect
Style refStyles;
        foreach (Paragraph para in rangeToInspect.Paragraphs)
        {
            refStyles = para.get_Style();
            if (refStyles != null)
            {
                if (refStyles.NameLocal.Contains("Heading 1", StringComparison.OrdinalIgnoreCase))
                {
                    //Do the stuff here with Heading
                }
            }
        }