I have an apps script which takes email addresses from one spreadsheet from multiple cells and adds them them to another spreadsheet into 1 cell only. Currently the email addresses are added to that cell and separated by a ", ".
I would like to add the email addresses into that same cell but add a new line after each address.
I know it is possible to have new lines in a cell when manually adding text, by typing CTRL-Enter.
How can this be achieved in apps script?
I have so far tried to append "\n" or "\r" or "\r\n" to the string, to no avail, so I have reverted my code back to adding ", " instead.
sheet = SpreadsheetApp.getActiveSheet();
sheet.clear();
sheet.appendRow(["Num Emails", "Emails"]);
var LMEmails = "";
var count = 0;
for (var i = 0; i < reviewers.LMEmails.length; i++) {
if (count) {
LMEmails += ", " + reviewers.LMEmails[i];
} else {
LMEmails += reviewers.LMEmails[i];
}
count++;
}
data = [count, LMEmails];
sheet.appendRow(data);
If anyone could help, I would very much appreciate it
Regards Crouz
\n
is working just fine withsetValue()
. What doesLMEmails += "\n" + reviewers.LMEmails[i];
leads to? – Kriggsss.getRange( ss.getLastRow(), 0, 1, 2).setValue(data);
– Kriggsss.getRange( ss.getLastRow() + 1, 1, 1, 2).setValue(data);
– Kriggs