Google Apps Script - convert to CSV

*爱你&永不变心* 提交于 2019-11-29 16:43:13

Once you get the values of a spreadsheet range, you'll end up with a two dimensional array. So to convert it, you'll have to construct a string that joins array array cell elements with a comma and join the rows with a new-line ("\n");

Haven't tested this, but should be something like this.

var range = someSheet.getRange("A2:B" + someSheet.getLastRow());
var vals = range.getValues();
//let's pretend vals is as below
var vals = [["A2","B2"], ["A3", "B3"]];
var csvString = vals.join("\n");
DriveApp.createFile("mycsv.csv", csvString);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!