侧边栏专注于特定单元格



尝试使用侧边栏作为几个单元格的导航栏,因为我有一个相当大的数据库电子表格。 我在侧边栏中有几个链接,单击时应该选择某个单元格。

问题是我最多只想创建一个传递参数的函数,例如:

<a onclick="goto('A20');">Go to A20</a>

或者,如果可能的话,我想在 html 标签中包含单行代码。

任何希望将不胜感激,提前感谢大家的帮助。

下面是应用程序的最小代码集。

Code.gs

function onOpen(){
SpreadsheetApp.getUi().createMenu("A")
.addItem("B", "showSidebar")
.addToUi();  
}
function showSidebar(){
SpreadsheetApp.getUi()
.showSidebar(HtmlService.createHtmlOutputFromFile("Sidebar"));
}
function goto(a1Notation){
SpreadsheetApp.getActiveSheet().setActiveSelection(a1Notation);
}

侧边栏.html

<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<a href="javascript:google.script.run.goto('A20');">Go to A20</a><br />
<a href="javascript:google.script.run.goto('A20:C1');">Go to A20:C1</a><br />
<a href="javascript:google.script.run.goto('A2');">Go to A2</a><br />
</body>
</html>

最新更新