按名称打开 Google Docs 电子表格 [英] Open Google Docs Spreadsheet by name
问题描述
我有一个脚本正在获取输入数据并将其发送到电子表格的情况.过了一会儿,这个电子表格变得太大了.
I have a situation where a script is taking input data and sending it to a spreadsheet. After a while, this spreadsheet becomes too big.
现在我们必须手动将项目从主电子表格移动到新电子表格.原因是不是每个人都熟悉代码,愿意更改代码中的ID.
Right now we have to manually move the items from the the primary spreadsheet to a new one. The reason is that not everyone is familiar with the code and are willing to change the ID in the code.
我想知道是否可以按名称打开电子表格.如果没有,是否有更好的方法来实现我们所需要的(如上所述)
I would like to know if there is a way to open the spreadsheet by name. If not, is there a better way of achieving what we need (described above)
推荐答案
其中一个答案中使用的 DocsList 服务不再起作用,因为它已被折旧.我更新了我的脚本,使其看起来更像以下内容.
The DocsList service used in one of the answers no longer functions as it has been depreciated. I updated my scripts to look more like the following.
// Open the file
var FileIterator = DriveApp.getFilesByName(FileNameString);
while (FileIterator.hasNext())
{
var file = FileIterator.next();
if (file.getName() == FileNameString)
{
var Sheet = SpreadsheetApp.open(file);
var fileID = file.getId();
}
}
DocsList 的替代品是 DriveApp https://developers.google.com/apps-script/reference/drive/drive-app
The replacement for DocsList is DriveApp https://developers.google.com/apps-script/reference/drive/drive-app
这篇关于按名称打开 Google Docs 电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!