自定义电子表格GAS的文件夹

时间:2013-05-31 05:10:19

标签: google-apps-script

我有一个脚本可以让我创建一个电子表格,但我不知道它将在何处创建,我想自定义电子表格的创建位置。

var Today_Submit=Utilities.formatDate(Today_selected,"IST", "yyyy-MM-dd");
var Yesterday_Submit=Utilities.formatDate(Yesterday_Selected,"IST", "yyyy-MM-dd"); 
var source = SpreadsheetApp.getActiveSpreadsheet();
var model = source.getSheetByName("Reports Model");

// Create a new spreadsheet on Drive, named by date
var destination = SpreadsheetApp.create(Today_Submit+" MLD_status Main reports");

// Copy and rename the model sheet into new spreadsheet
var newSheet = model.copyTo(destination).setName(Today_Submit);
你能帮帮我吗?

1 个答案:

答案 0 :(得分:0)

不幸的是SpreadsheetApp类没有这个。您必须使用SpreadsheetDocsList混合来实现您想要的效果。

var destination = SpreadsheetApp.create(Today_Submit+" MLD_status Main reports");
var folder = DocsList.getFolder('myFolder');
DocsList.getFileById(destination.getId()).addToFolder(folder); 

请注意,我实际上没有测试过此代码,但使用了参考文档。如果有的话,请随时纠正语法和其他小错误。