通过Google Scripts将文件添加到Google云端硬盘

时间:2015-04-26 04:08:04

标签: google-apps-script google-sheets

在一个独立的Google脚本中,我使用其API创建了一个Google表格,使用了它的SpreadsheetApp.create()功能,并在电子表格中填入了数据。

我必须将此文件添加到Google云端硬盘,但我不知道如何。我假设create()方法没有自动将其添加到驱动器中。谢谢!

1 个答案:

答案 0 :(得分:0)

当您使用SpreadsheetApp.create()时,它会在您的云端硬盘中创建一个原生(显然)的新电子表格。没有必要将它添加到您的驱动器,它实际上没有任何意义。 您最终可以使用这个小代码轻松检查:

function testCreate(){
  var newSs = SpreadsheetApp.create("new test spreadsheet");
  Browser.msgBox("file in drive is "+DriveApp.getFileById(newSs.getId()).getName());
}

注意:从电子表格(任何电子表格)运行此操作,因为它使用仅适用于电子表格的Browser.msgBox()方法。

相关问题