Csv 从应用程序脚本设置文档类型
我每周通过电子邮件发送一个压缩的csv文件,并编写了一个google应用程序脚本,以从电子邮件中获取文件并保存到驱动器:Csv 从应用程序脚本设置文档类型,csv,google-apps-script,google-drive-api,google-sheets,Csv,Google Apps Script,Google Drive Api,Google Sheets,我每周通过电子邮件发送一个压缩的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', 'y
// 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工作表,因此提前提供的任何帮助也将被视为一个答案 找到它,比我想的容易多了 只需使用驱动器文件夹方法将文件的MIME类型设置为text/csv: file=folder.createFilenewName,unzipblob[0]。getDataAsString,text/csv
那么GSheets是一个右键单击选项 请注意,它很容易保存为新的工作表,问题也会消失。