跳到主要内容

GetElement

通过元素在文档中的位置返回元素。

语法

expression.GetElement(nPos);

expression - 表示 ApiDocumentContent 类的变量。

参数

名称必需/可选数据类型默认值描述
nPos必需number将从文档中获取的元素位置。

返回值

DocumentElement

示例

通过索引从文档内容中检索特定元素。

// How do I get a single element at a known position inside a document content in a document?

// Add text to a header paragraph by fetching it directly through its position index.

let doc = Api.GetDocument();
let section = doc.GetFinalSection();
let docContent = section.GetHeader("default", true);
let paragraph = docContent.GetElement(0);
paragraph.AddText("This is the text in the default header");