Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 通过脚本将单元格超链接指定给按钮_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 通过脚本将单元格超链接指定给按钮

Google apps script 通过脚本将单元格超链接指定给按钮,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我们这里讨论的是同一个电子表格,没有交叉链接。我只想要一个按钮跳到同一个电子表格的另一部分。我在网上找到的所有脚本都不会这样做,它们都会在一个新窗口中打开链接,在这个窗口中,你必须再次登录到谷歌,并授予一个无标题的项目(可能是脚本)编辑电子表格的权限。使用=Hyperlink看起来不太好,因为您必须将鼠标悬停在链接上,然后单击出现的小窗口 我希望这样的脚本存在,或者如果有人知道如何用宏或附加组件解决这个问题,我洗耳恭听。此函数跳到同一行的最后一列。运行showDialog()函数以显示侧栏,按钮

我们这里讨论的是同一个电子表格,没有交叉链接。我只想要一个按钮跳到同一个电子表格的另一部分。我在网上找到的所有脚本都不会这样做,它们都会在一个新窗口中打开链接,在这个窗口中,你必须再次登录到谷歌,并授予一个无标题的项目(可能是脚本)编辑电子表格的权限。使用=Hyperlink看起来不太好,因为您必须将鼠标悬停在链接上,然后单击出现的小窗口


我希望这样的脚本存在,或者如果有人知道如何用宏或附加组件解决这个问题,我洗耳恭听。

此函数跳到同一行的最后一列。运行showDialog()函数以显示侧栏,按钮位于侧栏顶部

function jump() {
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getActiveSheet();
  var rg=sh.getActiveRange();
  var col=rg.getColumn();
  var max=sh.getMaxColumns();
  var offset=max-col;
  rg.offset(0, offset).activate();
}

function showDialog() {
  var html='<input type="button" value="Jump" onClick="jump();" />';
  html+='<script>function jump(){google.script.run.jump();}</script>';
  var userInterface=HtmlService.createHtmlOutput(html);
  SpreadsheetApp.getUi().showSidebar(userInterface);
}
函数跳转(){
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var rg=sh.getActiveRange();
var col=rg.getColumn();
var max=sh.getMaxColumns();
var偏移=最大列;
rg.offset(0,offset).activate();
}
函数showDialog(){
var html='';
html+='function jump(){google.script.run.jump();}';
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showSidebar(用户界面);
}

此函数跳转到同一行的最后一列。运行showDialog()函数以显示侧栏,按钮位于侧栏顶部

function jump() {
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getActiveSheet();
  var rg=sh.getActiveRange();
  var col=rg.getColumn();
  var max=sh.getMaxColumns();
  var offset=max-col;
  rg.offset(0, offset).activate();
}

function showDialog() {
  var html='<input type="button" value="Jump" onClick="jump();" />';
  html+='<script>function jump(){google.script.run.jump();}</script>';
  var userInterface=HtmlService.createHtmlOutput(html);
  SpreadsheetApp.getUi().showSidebar(userInterface);
}
函数跳转(){
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var rg=sh.getActiveRange();
var col=rg.getColumn();
var max=sh.getMaxColumns();
var偏移=最大列;
rg.offset(0,offset).activate();
}
函数showDialog(){
var html='';
html+='function jump(){google.script.run.jump();}';
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showSidebar(用户界面);
}

这是一个简单的脚本,它将在电子表格UI上创建一个菜单(“操作”)[1],其中有一个选项“转到单元格”,单击该选项将运行activateCell函数,该函数将激活您在getRange函数[2]上选择作为参数的单元格

function onOpen() {
  SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
  .createMenu('Actions')
  .addItem('Go to Cell', 'activateCell')
  .addToUi();  
}

function activateCell() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Sheet1"); 
  var range = sheet.getRange("Z40").activate();  //Change the cell to whichever you want
}
[1]


[2]

这里有一个简单的脚本,它将在电子表格UI上创建一个菜单(“操作”)[1],其中有一个选项“转到单元格”,单击该选项将运行activateCell函数,该函数将激活您在getRange函数[2]上选择作为参数的单元格

function onOpen() {
  SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
  .createMenu('Actions')
  .addItem('Go to Cell', 'activateCell')
  .addToUi();  
}

function activateCell() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Sheet1"); 
  var range = sheet.getRange("Z40").activate();  //Change the cell to whichever you want
}
[1]

[2]