通过ID获取Google表单? [英] Get Google Sheet by ID?
本文介绍了通过ID获取Google表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道Google Apps Script有一个 getSheetId()方法为表单类,但有什么办法通过引用ID在电子表格中选择表单?
I know that Google Apps Script has a getSheetId() method for the Sheet Class, but is there any way to select a sheet within a spreadsheet by referencing the ID?
在电子表格文档。
推荐答案
您可以使用如下所示的内容:
You can use something like this :
function getSheetIdtest(){
var id = SpreadsheetApp.getActiveSheet().getSheetId();// get the actual id
Logger.log(id);// log
var sheets = SpreadsheetApp.getActive().getSheets();
for(var n in sheets){ // iterate all sheets and compare ids
if(sheets[n].getSheetId()==id){break}
}
Logger.log('tab index = '+n);// your result, test below just to confirm the value
var currentSheetName = SpreadsheetApp.getActive().getSheets()[n].getName();
Logger.log('current Sheet Name = '+currentSheetName);
}
这篇关于通过ID获取Google表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文