I have a sheet and need to get the values (email addresses) of a certain column, which is C in this case. Let's assume there are three emails in the column. The log gives me:
"[[email1], [email2], [email3]]"
In order to continue with the script I need to have the array looking like this:
"[email1, email2, email3]"
So just without the outer brackets. I know I can target just "[email1]" by adding "[0]" behind ".getValues()". I tried something like "[[all]]" but it didn't work. What do I have to change? I know, this is probably pretty basic but I'm an absolute beginner, thankful for any help.
function myFunction() {
// Variables
var id = "ID";
var spreadSheet = SpreadsheetApp.openById(id);
var inputSheet = spreadSheet.getSheetByName("inputSheet");
var inputLR = inputSheet.getLastRow();
var emailsAll = inputSheet.getRange(2, 3, inputLR).getValues();
Logger.log(emailsAll);
}
Try
Array#map
orArray#forEach
getValues()
return a two-dimensional array representing the rows and columns in the range. Read more in the developer reference.Iterate over this array to access the values.
Reference material about
for
loops here and here.Example in plain js: