Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.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,是否可以通过谷歌应用程序脚本打开谷歌电子表格? 我正在尝试创建一种链接到电子表格中某个单元格的方法,但无法通过脚本(部署为web应用程序)打开工作表。 我想打开电子表格,然后设置活动工作表和范围(打开电子表格时,我知道如何执行后者) 提前谢谢 编辑 以下是我当前的代码: function doGet(e){ var ss = SpreadsheetApp.openById("[id]"); SpreadsheetApp.setActiveSpreadsheet(ss); var sh

是否可以通过谷歌应用程序脚本打开谷歌电子表格?
我正在尝试创建一种链接到电子表格中某个单元格的方法,但无法通过脚本(部署为web应用程序)打开工作表。
我想打开电子表格,然后设置活动工作表和范围(打开电子表格时,我知道如何执行后者)

提前谢谢

编辑
以下是我当前的代码:

function doGet(e){
  var ss = SpreadsheetApp.openById("[id]");
  SpreadsheetApp.setActiveSpreadsheet(ss);
  var sheet = ss.getSheetByName("Kunder");
  var row = Number(e.parameter.row); 
  var col = Number(e.parameter.col); 
  var range = sheet.getRange(row, col);

  //OPEN THE SPREADSHEET HERE

  SpreadsheetApp.setActiveSheet(sheet);
  SpreadsheetApp.setActiveRange(range);
}

您需要为电子表格使用正确的ID。找到它的一种方法是:

  • 在Google Drive中打开包含的文件夹
  • 右键单击电子表格
  • 选择获取链接
  • 复制显示的URL
  • URL的格式为:

    使用id参数值作为openById的参数,例如:

    var ss=SpreadsheetApp.openById(“xoxoxoxoxoxoxo”)

    函数myFunction(){
    var js=”\
    \
    打开窗户https://tanaikech.github.io/","空白","宽800,高600",\
    google.script.host.close()\
    \
    ";
    var html=HtmlService.createHtmlOutput(js)
    .设置高度(10)
    .设置宽度(100);
    SpreadsheetApp.getUi().showModalDialog(html,“正在加载”);//如果在电子表格上使用此选项
    //DocumentApp.getUi().showModalDialog(html,“正在加载”);//如果您在文档上使用此选项
    //SlidesApp.getUi().showModalDialog(html,“正在加载”);//如果在幻灯片上使用此选项
    }
    
    我修改了链接和窗口大小,这样它就可以在一个新的选项卡中打开(您可能还可以删除
    “u blank”

    \
    打开窗户https://docs.google.com/spreadsheets/d/“+custFileID.id+”,“_blank”)\
    google.script.host.close()\
    \
    

    custFileID
    是另一个查找文件ID的函数。只需将其替换为您自己的变量或文件ID即可。

    但这实际上不会打开文件。根据文档://注意,电子表格不是在客户端实际打开的。什么是空白?它需要使用一个特殊的库吗?也就是说,在一个新窗口中打开浏览器只需要HTML。不需要图书馆。您还可以将窗口命名为“\u blank”。