跳到主要内容

SetEndPos

设置当前范围对象的结束位置。

语法

expression.SetEndPos(nPos);

expression - 表示 ApiRange 类的变量。

参数

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

返回值

boolean

示例

此示例设置给定范围对象的结束位置。

// Get the end index of the range and display it.

// Retrieve a range of the paragraph and show its last position.

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