跳到主要内容

AddHyperlink

向指定范围添加超链接。

语法

expression.AddHyperlink(sLink, sScreenTipText, sBookmarkName);

expression - 表示 ApiRange 类的变量。

参数

名称必需/可选数据类型默认值描述
sLink必需string链接地址。
sScreenTipText必需string屏幕提示文本。
sBookmarkName必需string书签名称

返回值

ApiHyperlink

示例

此示例向指定范围添加超链接。

// Insert a link to the range.

// Get range and add a hyperlink to it.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range = doc.GetRange(0, 11);
range.AddHyperlink("https://www.onlyoffice.com/", "Main portal");