使用应用程序脚本在新的Google表格中插入超链接 [英] Inserting Hyperlinks in the new Google Sheets with App Script

查看:341
本文介绍了使用应用程序脚本在新的Google表格中插入超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当前版本的Google表格中,要将超链接插入到单元格中,您可以执行此操作。

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 + '")')

在Google表格的新版本版本中,超链接插入方式不同,您可以这样做。

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

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

然而,我遇到了一个问题,电子表格中插入的值并不是我所期望的。在显示插入的链接的图像中,在= HYPERLINK之前插入了一个 - 我不知道在哪里这是来自。任何想法?

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?

推荐答案

将公式设置为Sheet范围时,应始终使用 setFormula (或其变体)而不是的setValue 。尽管在使用 setValue 时可能会有一些公式可用,但您看到了一些怪癖。

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.

这篇关于使用应用程序脚本在新的Google表格中插入超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆