我每周都会通过电子邮件发送一个压缩的csv文件,并编写了一个google应用程序脚本,以便从电子邮件中获取该文件并保存到驱动器中:
// unzip it
var unzipblob = Utilities.unzip(att[z]);
// Create with a unique filename using date of email
var newName = 'provider_stats-' + Utilities.formatDate(date, 'GMT', 'yyyy-MM-dd') + '.csv';
// Save the first file (there's only one) in the zip
file = folder.createFile(newName, unzipblob[0].getDataAsString());
file.setDescription(newName);
这很好用,但我注意到在我保存它的驱动器文件夹中,它似乎与我手动执行的文件类型不同。其他的提供我"在Google表格中打开"右键单击时的选项,但不是从脚本中保存的选项。
我知道如何设置文档类型或格式,以便可以直接在Google表格中打开吗?
我的下一步是直接保存为Google表格,因此提前获得的任何帮助也可以作为答案!
答案 0 :(得分:0)
发现它,我想的更容易!
只需将文件的MIME类型设置为" text / csv"使用Drive Folder方法:
file = folder.createFile(newName,unzipblob [0] .getDataAsString()," text / csv");
然后GSheets是一个右键单击选项!