I am trying to create a list of tabs based on values in a row, as I have previously done with values in a column (The script here is an example test as I was trying to identify the issue, not the actual script used). However, the forEach()
function is working differently and I do not understand why. Below I will append two sets of scripts and their results.
For column:
var app = SpreadsheetApp;
var ss = app.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var range = sheet.getRange(1,1,5,1);
var STlist = [];
range.getValues().forEach(function(x){
Logger.log(x + " why");
STlist.push(x);
});
Logger.log(STlist);
}
Output for column
[20-02-28 12:10:58:012 HKT] z why
[20-02-28 12:10:58:018 HKT] a why
[20-02-28 12:10:58:021 HKT] b why
[20-02-28 12:10:58:023 HKT] c why
[20-02-28 12:10:58:026 HKT] d why
[20-02-28 12:10:58:029 HKT] [[z], [a], [b], [c], [d]]
For Row
var app = SpreadsheetApp;
var ss = app.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var range = sheet.getRange(1,1,1,5);
var STlist = [];
range.getValues().forEach(function(x){
Logger.log(x + " why");
STlist.push(x);
});
Logger.log(STlist);
}
Output for row
[20-02-28 12:11:35:013 HKT] z,x,d,v,g why
[20-02-28 12:11:35:018 HKT] [[z, x, d, v, g]]
Would it be possible for the row format to work the same as the column format? As I was expecting to see the same results but I got different results.
Thank you