确定段落是标准文本还是标题
Determine if the paragraph is a standard text or a heading
有没有办法确定该段落是标准文本还是标题?
不使用任何第三方组件 Spire.Doc
请注意以下代码:仅当未重命名 Word 样式 "Heading 1" 时才有效。
object thisTempStyle = p.get_Style();
Style thisparagraphStyle = thisTempStyle as Style;
string actualStyle = thisparagraphStyle.NameLocal;
if (actualStyle == "Heading 1")
...
所以,我想在不知道标题的情况下获取标题。
谢谢
您还可以检查段落的大纲级别
(https://msdn.microsoft.com/en-us/library/office/ff839401.aspx).
switch(thisparagraphStyle.ParagraphFormat.OutlineLevel)
{
case WdOutlineLevel.wdOutlineLevel1:
// Heading 1
break;
case WdOutlineLevel.wdOutlineLevelBodyText:
// Body Paragraph
break;
}
有没有办法确定该段落是标准文本还是标题?
不使用任何第三方组件 Spire.Doc
请注意以下代码:仅当未重命名 Word 样式 "Heading 1" 时才有效。
object thisTempStyle = p.get_Style();
Style thisparagraphStyle = thisTempStyle as Style;
string actualStyle = thisparagraphStyle.NameLocal;
if (actualStyle == "Heading 1")
...
所以,我想在不知道标题的情况下获取标题。
谢谢
您还可以检查段落的大纲级别 (https://msdn.microsoft.com/en-us/library/office/ff839401.aspx).
switch(thisparagraphStyle.ParagraphFormat.OutlineLevel)
{
case WdOutlineLevel.wdOutlineLevel1:
// Heading 1
break;
case WdOutlineLevel.wdOutlineLevelBodyText:
// Body Paragraph
break;
}