Inserting Hyperlinks in the new Google Sheets with

2019-04-25 08:26发布

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?

2条回答
【Aperson】
2楼-- · 2019-04-25 08:53

that " inside apostrophes are not text so you should change " to \"

~~~~~~~~~~~~~setValue('=HYPERLINK(\"' + ontologyObject.accession + '\",\"' + ontologyObjectTerm + '\")')

other functions too

查看更多
地球回转人心会变
3楼-- · 2019-04-25 08:57

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.

查看更多
登录 后发表回答