I have a Spreadsheet with only one column and a rows of names:
Using Google Apps Script, I have made a telegram bot with multiple functions - and as one of those functions I want the bot to post the content of this sheet as a list.
I can easily pull the rows as an array using:
function sendlist() {
var rows = SpreadsheetApp.openById(neueliste).getSheetByName('Liste').getDataRange().getValues();
Logger.log(rows);
}
giving me
Now, my question is, how can I post this array as a formatted "list", in the style of
- Entry 1
- Entry 2
- Entry 3
?
Adding names to the list isn't a problem, I am using this for that:
if ((text.startsWith('/addlist')) {
var sheetName = "Liste";
var sheet = SpreadsheetApp.openById(ssId).getSheetByName(sheetName) ? SpreadsheetApp.openById(ssId).getSheetByName(sheetName) : SpreadsheetApp.openById(ssId).insertSheet(sheetName);
var args = text.split(" ");
var arg1 = args[1];
sheet.appendRow([name,arg1]);
sendText(id,"Hello " + name + " your name '" + arg1 + "' has been added.");
}
Works like a treat. But I can't wrap my head around how to do the sendText(id, [...])
to post the content of rows as a formatted list.
Any help?
I looked at using the forEach function, but that didnt get me anywhere so far.