在特定文件夹中创建Google电子表格 [英] create a Google spreadsheet in a particular folder

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

问题描述

这个问题教导如何调整将文件的文件夹移动到特定的文件夹中,然后移出根目录。

this question teaches how to adjust the folders of a file to move it into a particular folder, and out of the root.

它还建议使用folder.createFile直接在所需的文件夹中创建它。 。但它看起来createFile只适用于文档...有没有办法直接在特定的文件夹中创建电子表格?

It also suggests using folder.createFile to create it directly in the desired folder... but it appears createFile only applies to Docs... is there a way to create a spreadsheet directly in a particular folder?

推荐答案

由于DocsList已被弃用,目前下面的解决方案工作:

Since DocsList is deprecated, currently the following solution works:

var folder=DriveApp.getFoldersByName(folderName).next();//gets first folder with the given foldername
var file=SpreadsheetApp.create(fileName);
var copyFile=DriveApp.getFileById(file.getId());
folder.addFile(copyFile);
DriveApp.getRootFolder().removeFile(copyFile);

这篇关于在特定文件夹中创建Google电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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