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。找到它的一种方法是:
函数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”。