跳到主要内容

SetStartPos

设置当前范围对象的起始位置。

语法

expression.SetStartPos(nPos);

expression - 表示 ApiRange 类的变量。

参数

名称必需/可选数据类型默认值描述
nPos必需Number起始位置。

返回值

boolean

示例

将文本选区的起始位置移动到文档中的不同位置。

// How do I change where a text range starts without altering where it ends in a document?

// Trim or expand the leading edge of a selected region to cover a different set of words in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range = paragraph.GetRange();
range.SetStartPos(12);
range.SetBold(true);