Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting Hyperlinks in the new Google Sheets with App Script

In the current version of Google Sheet, to insert a hyperlink in to a cell, you would do this

sheet.getRange(row, selectedColumn).setValue('=hyperlink("' + ontologyObject.accession + '";"' + ontologyObjectTerm + '")')

In the new version of Google Sheets, the hyperlink insertion is different, you do this.

sheet.getRange(row, selectedColumn).setValue('=HYPERLINK("' + ontologyObject.accession + '","' + ontologyObjectTerm + '")')

However, I have a problem in that the inserted value in the spreadsheet is not what I expect. In this image showing the inserted link, there is a ' inserted before the =HYPERLINK - I've no idea where this is coming from. Any ideas?

like image 291
Eamonn Avatar asked Mar 13 '14 13:03

Eamonn


People also ask

How do I hyperlink a URL in Google Sheets?

To create a hyperlink in Google Sheets, start by highlighting the text you want to turn into a link. Then, click on the "HYPERLINK" button in the toolbar and enter the web address you want to link to. When you're done, click "OK" and the text will turn into a link.


1 Answers

When setting formulas to a Sheet range you should always use setFormula (or its variants) instead of setValue. Even though some formulas may work when using setValue, there's some quirks as you saw.

like image 144
Henrique G. Abreu Avatar answered Nov 05 '22 16:11

Henrique G. Abreu