Skip to main content

SetHyperlink

Adds a hyperlink to the specified range.

Syntax​

expression.SetHyperlink(range, address, subAddress, screenTip, textToDisplay);

expression - A variable that represents an ApiWorksheet class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
rangeRequiredstringThe range where the hyperlink will be added to.
addressRequiredstringThe link address.
subAddressOptionalstringThe link subaddress to insert internal sheet hyperlinks.
screenTipOptionalstringThe screen tip text.
textToDisplayOptionalstringThe link text that will be displayed on the sheet.

Returns​

boolean

Example​

Attach a clickable hyperlink to a cell range in a spreadsheet.

// How do I add a hyperlink to a cell in a spreadsheet?

// Link a cell to an external URL so users can navigate to it directly in a spreadsheet.

let worksheet = Api.GetActiveSheet();
const logoUrl = 'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png';
worksheet.SetHyperlink('A1', logoUrl, null, 'ONLYOFFICE for developers', 'Api ONLYOFFICE');