我在Google Apps脚本中编写了一个脚本,用于从Google表格创建新表单。 如何将表单自动保存在驱动器的特定文件夹中?
答案 0 :(得分:2)
您不能说,但我们假设您正在创建Google表单,例如像这样:
getId()
在这种情况下,这是一个将该表单的云端硬盘文件添加到您指定的云端硬盘文件夹的功能。注意 - 此功能可以支持文档,电子表格和其他文件类型...任何具有/**
* Places file for given item into given folder.
* If the item is an object that does not support the getId() method or
* the folder is not a Folder object, an error will be thrown.
* From: http://stackoverflow.com/a/38042090/1677912
*
* @param {Object} item Any object that has an ID and is also a Drive File.
* @param {Folder} folder Google Drive Folder object.
*/
function saveItemInFolder(item,folder) {
var id = item.getId(); // Will throw error if getId() not supported.
folder.addFile(DriveApp.getFileById(id));
}
方法的Google Apps脚本对象,也可以表示为驱动器文件。
// Create temporary form
var form=FormApp.create('Delete me');
// Get temporary folder
var folder=DriveApp.getFoldersByName('Delete me').next();
saveItemInFolder(form,folder);
示例:
Exam
student_id | exam_date | status
1 2016-01-01 absence
2 2016-01-28 pass
3 2016-02-03 absence
1 2016-02-08 pass
4 2016-02-22 pass
5 2016-02-27 pass
6 2016-02-28 fail
5 2016-03-01 fail
3 2016-03-24 fail
7 2016-03-30 pass
答案 1 :(得分:0)
如果您有ID
,也可以使用DriveApp实际移动表单