Export Google spreadsheet to text file using script

孤街浪徒 提交于 2019-12-06 03:43:32

Here is a simple export function that works for me: it exports the current sheet as tab-delimited text file, whose name includes the date of creation.

You can set it to be triggered on edit using Resources > Current Project's Triggers in the Script Editor.

function export() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var values = sheet.getDataRange().getValues();
  var text = values.map(function (a) {return a.join('\t');}).join('\n');
  DriveApp.createFile('Data as of ' + new Date(), text);
}

Depending on your editor/OS, you may want join('\r\n') instead of join('\n') here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!