Skip to main content

insertLink()

Description

inserts/removes a hyperlink in a cell

Usage

insertLink( 
cell: string,
link? : {
text?: string,
href: string
}
): void;

Parameters

  • cell - (required) the id of a cell
  • link - (optional) an object with configuration of a link:
    • text - (optional) a text you want to display for a hyperlink
    • href - (required) the URL of the page the hyperlink leads to
info

To remove a hyperlink but keep the text, call the method without the link parameter.

Example

const spreadsheet = new dhx.Spreadsheet("spreadsheet", {});
spreadsheet.parse(data);

// insert a link in "A2" cell
spreadsheet.insertLink("A2", {
text:"DHX Spreadsheet", href: "https://dhtmlx.com/docs/products/dhtmlxSpreadsheet/"
});

// remove a link from "A2" cell
spreadsheet.insertLink("A2");

Change log: Added in v5.0

Related article: Work with Spreadsheet