Section
Section
概述
Section 是 Aspose.Words FOSS 中用于 .NET 的类。继承自:CompositeNode,ISectionAttrSource。
表示文档中的单个章节。
此类提供 34 个用于在 .NET 程序中处理 Section 对象的方法。可用的方法包括:Accept、AcceptEnd、AcceptStart、AppendChild、AppendContent、ClearContent、ClearHeadersFooters、Clone、CreateNavigator、DeleteHeaderFooterShapes、EnsureMinimum、GetAncestor,以及另外 21 个方法。安装 Aspose.Words FOSS for .NET 包后,所有公共成员对任何 .NET 应用程序均可访问。属性:Body、Count、CustomNodeId、Document、FirstChild、HasChildNodes,以及另外 10 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
NodeType | NodeType | 读取 | 返回 Section。 |
Body | Body | 读取 | 返回该 section 的 Body 子节点。 |
HeadersFooters | HeaderFooterCollection | 读取 | 提供对节的页眉和页脚节点的访问。 |
PageSetup | PageSetup | 读取 | 返回一个表示页面设置和节属性的对象。 |
ProtectedForForms | bool | 读写 | 如果该节对表单受保护,则为 True。 |
IsComposite | bool | 读取 | 返回 true,因为此节点可以拥有子节点。 |
HasChildNodes | bool | 读取 | 如果此节点有任何子节点,则返回 true。 |
FirstChild | Node | 读取 | 获取节点的第一个子节点。 |
LastChild | Node | 读取 | 获取节点的最后一个子节点。 |
Count | int | 读取 | 获取此节点的直接子节点数量。 |
ParentNode | CompositeNode | 读取 | 获取此节点的直接父节点。 |
Document | DocumentBase | 读取 | 获取此节点所属的文档。 |
PreviousSibling | Node | 读取 | 获取紧邻此节点的前一个节点。 |
NextSibling | Node | 读取 | 获取紧随此节点的节点。 |
Range | Range | 读取 | 返回一个 Range 对象,表示包含在此节点中的文档部分。 |
CustomNodeId | int | 读写 | 指定自定义节点标识符。 |
方法
| 签名 | 描述 |
|---|---|
Section(doc: DocumentBase) | 初始化 Section 类的新实例。 |
Clone() | 创建此 section 的副本。 |
Accept(visitor: DocumentVisitor) | 调用 VisitSectionStart,然后对该 section 的所有子节点调用 Accept,最后调用 VisitSectionEnd。 |
AcceptStart(visitor: DocumentVisitor) | 在此 Section 实例上调用 AcceptStart(visitor)。 |
AcceptEnd(visitor: DocumentVisitor) | 在此 Section 实例上调用 AcceptEnd(visitor)。 |
PrependContent(sourceSection: Section) | 在本节的开头插入源节内容的副本。 |
AppendContent(sourceSection: Section) | 在本节的结尾插入源节内容的副本。 |
ClearContent() | 清空该节。 |
ClearHeadersFooters() | 清除本节的页眉和页脚。 |
ClearHeadersFooters(preserveWatermarks: bool) | 清除本节的页眉和页脚。 |
DeleteHeaderFooterShapes() | 删除本节的页眉和页脚中的所有形状(绘图对象)。 |
EnsureMinimum() | 确保该节的正文包含一个段落。 |
GetText() | 获取此节点及其所有子节点的文本。 |
GetChildNodes(nodeType: NodeType, isDeep: bool) | 返回一个匹配指定类型的子节点集合。 |
GetChild(nodeType: NodeType, index: int, isDeep: bool) | 返回第 N 个匹配指定类型的子节点。 |
SelectNodes(xpath: string) | 选择匹配 XPath 表达式的节点列表。 |
SelectSingleNode(xpath: string) | 选择匹配 XPath 表达式的第一个节点。 |
GetEnumerator() | 为此节点的子节点提供 for each 风格的迭代支持。 |
AppendChild(newChild: T) | 将指定节点添加到此节点的子节点列表末尾。 |
PrependChild(newChild: T) | 将指定节点添加到此节点的子节点列表开头。 |
InsertAfter(newChild: T, refChild: Node) | 在指定的参考节点之后立即插入指定节点。 |
InsertBefore(newChild: T, refChild: Node) | 在指定的参考节点之前立即插入指定的节点。 |
RemoveChild(oldChild: T) | 删除指定的子节点。 |
RemoveAllChildren() | 删除当前节点的所有子节点。 |
RemoveSmartTags() | 删除当前节点的所有 SmartTag 后代节点。 |
IndexOf(child: Node) | 返回子节点数组中指定子节点的索引。 |
CreateNavigator() | 创建可用于遍历和读取节点的导航器。 |
GetAncestor(ancestorType: Type) | 获取指定对象类型的第一个祖先。 |
GetAncestorOf() | 在此 Section 实例上调用 GetAncestorOf。 |
Remove() | 从父级中移除自身。 |
NextPreOrder(rootNode: Node) | 根据前序树遍历算法获取下一个节点。 |
PreviousPreOrder(rootNode: Node) | 根据前序树遍历算法获取上一个节点。 |
ToString(saveFormat: SaveFormat) | 将节点的内容导出为指定格式的字符串。 |
NodeTypeToString(nodeType: NodeType) | 一个将节点类型枚举值转换为用户友好字符串的实用方法。 |