P
P
Peter2015-11-19 18:02:49
Google Sheets
Peter, 2015-11-19 18:02:49

How to insert array in google spreadsheet?

I'm trying to insert data into a table. Swears that setValue has no rights to insert data. Google does not help, I do not understand what the problem is.

function addData(type){

/*
Somehow I get 2d array: result
*/

  var arr = [];
  var c = [];
  var i, j;
  for (i = 0;i < result.length-1; i++) {
    c=[];
    for (j = 0; j < result[0].length; j++){
      c.push(result[i][j]);
    }
    arr.push(c);
  }

  var sheet = SpreadsheetApp.getActiveSheet();    
  sheet.getRange(1, 1, i+1, j+1).setValues(arr);
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question