Skip to content
Julian Halliwell edited this page Mar 3, 2023 · 5 revisions

Adds a hyperlink to a cell. If the cell doesn't exist it will be created.

setCellHyperLink( workbook, link, row, column[, cellValue[, type,[ format,[ tooltip ] ] ] ] )

Required arguments

  • workbook spreadsheet object
  • link string: the URL or target of the hyperlink
  • row numeric
  • column numeric

Optional arguments

  • cellValue any value to set in the cell which will be hyperlinked
  • type string default="URL": the type of hyperlink. Possible values: URL, Email, File (local file), Document (i.e. another part of the spreadsheet)
  • format struct OR cellStyle object default={ color: "BLUE", underline: true }: See formatting options
  • tooltip string: Text to appear when hovering over the hyperlink (NB: XLSX only and may not be supported by all spreadsheet software)

Chainable? Yes.

Example 1 external URL

spreadsheet = New spreadsheet();
workbook = spreadsheet.new();
spreadsheet.setCellHyperLink( workbook, "https://github.com/", 1, 1 );

Example 2 link to a local file

spreadsheet = New spreadsheet();
workbook = spreadsheet.new();
spreadsheet.setCellHyperLink( workbook, "anotherSpreadsheet.xls", 1, 1 );

Example 3 link to another cell in the same workbook

spreadsheet = New spreadsheet();
workbook = spreadsheet.new();
spreadsheet.setCellValue( workbook, "Please link to me", 1, 1 );
spreadsheet.setCellHyperLink( workbook, "'Sheet1'!A1", 2, 1, "OK I will" );
Clone this wiki locally