Google应用电子表格父级文件夹ID [英] Google apps spreadsheet parents folder ID

查看:161
本文介绍了Google应用电子表格父级文件夹ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google电子表格,用于跟踪电子表格所在文件夹内的文件及其名称。

我已查找并无法找到如何获取位置或ID

在MS CMD脚本中,它将是%〜dp0。

如何在谷歌应用程序电子表格脚本中执行此操作。

  function FnctnMenuUpdateGetLocation(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var SSID = ss.get.getId();
var file = DocsList.getFileById(SSID);

Browser.msgBox(SSID);
Browser.msgBox(add);
}

https://docs.google.com/spreadsheet/ccc?key=0AmsQN3N9km70dGwtLTJXVVBzbmJhdmE5OFpkbTVxelE&usp=sharing
ya,我是在这里工作

这是一张活页



从我有什么你如何获得电子表格的地址在谷歌从电子表格中驱动

我将添加文件夹/目录和我需要的文件


因为google文档是而不是谷歌驱动器从Spreadsheet到谷歌驱动器的界面如何

解决方案

Document Service和Drive Service都可以报告电子表格所在的文件夹。



以下是使用这两种服务更新您的函数,以显示包含电子表格的文件夹的名称。



$ b

 函数FnctnMenuUpdateGetLocation(){
var ss = SpreadsheetApp.getActiveSpreadsheet() ;
var SSID = ss.getId();

var fileInDocs = DocsList.getFileById(SSID);
var folderInDocs = fileInDocs.getParents()[0] .getName();

var fileInDrive = DriveApp.getFolderById(SSID);
var folderinDrive = fileInDrive.getParents()。next()。getName();

Browser.msgBox(Docs说:+ folderInDocs +
,Drive说:+ folderinDrive);
}

文档服务的 .getParents()方法返回一个文件夹对象的数组,而Drive的返回一个迭代器,所以一旦你拥有了所有这些文件夹的细节如何检索特定的父文件夹不同。



请注意,电子表格可能会被包含在多个文件夹中......在这种情况下,我们假设列表中的第一个文件夹是唯一的文件夹 - 这种假设可能是无效的。


I have a google spreadsheet that is keeping track of the files and their names that are inside the folder where the spreadsheet is.
I have looked and can not find how to get the location or ID of that sheet
In MS CMD script it would be "%~dp0".
How to do this in google apps spreadsheet script.

 function FnctnMenuUpdateGetLocation() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
  var SSID=ss.get.getId();
  var file = DocsList.getFileById(SSID);

  Browser.msgBox(SSID);
  Browser.msgBox(add);
}

https://docs.google.com/spreadsheet/ccc?key=0AmsQN3N9km70dGwtLTJXVVBzbmJhdmE5OFpkbTVxelE&usp=sharing ya, I am working in it
this is a live sheet

From what I have how do you get the address of the spreadsheet in google drive
from the spread sheet I will be having it add folder/dir and file that I need

since google docs is not google drive how is the interface from Spreadsheet to the google drive

解决方案

Both the Document Service and Drive Service can report which folder(s) a spreadsheet is in.

Here's your function, updated to show the name of a folder that contains the spreadsheet, using both services.

function FnctnMenuUpdateGetLocation() {
   var ss = SpreadsheetApp.getActiveSpreadsheet();
   var SSID=ss.getId();

   var fileInDocs = DocsList.getFileById(SSID);
   var folderInDocs = fileInDocs.getParents()[0].getName();

   var fileInDrive = DriveApp.getFolderById(SSID);
   var folderinDrive = fileInDrive.getParents().next().getName();

   Browser.msgBox("Docs says: " + folderInDocs +
                  ", Drive says: " + folderinDrive);
}

Document Service's .getParents() method returns an array of folder objects, while Drive's returns an iterator, so the details of how to retrieve a specific parent folder(s) once you've got all of them differs.

Note that a spreadsheet may be "contained" in multiple folders... in this case, we've assumed that the first folder in the list is the only one - that assumption may be invalid.

这篇关于Google应用电子表格父级文件夹ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆