I'm working in an sidebar menu in an google sheet, to set some variables that i need in my script.
My script is already working. It is easy, on form submit, it will create an event in my calendar.
However, in order to simplify the installation of my script, I would like to show a dropdown list in my sidebar with the names of all the sheet of my worksheet.
I see various post, that show how to do a dropdown list like this :
- How to create a drop down list in Input Box?
- How can I create a HTML dialog box that contains a dropdown list?
But this is not my problem, my problem is how to get the list of the sheet and put it in a dropdown list.
Thanks for your help,
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{name: "Sync Calendar Now", functionName: "syncActive"}];
entries.push(null); // adding line separator
entries.push({name: "Settings", functionName: "paramID"});
spreadsheet.addMenu(sheetName, entries);
};
function paramID() {
//TODO : Mettre ID calendrier ici :)
var html = HtmlService.createHtmlOutputFromFile('SideBar')
.setTitle('My custom sidebar')
.setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.showSidebar(html);
}
There is how i get the list names of the sheets
function getListNames(){
var out = new Array()
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for (var i=0 ; i<sheets.length ; i++) out.push( sheets[i].getName() )
Logger.log(out);
return out
}
For exemple, I have in my worksheet : Sheet 1 , Sheet 2 , Sheet 3
When my sidebar open, i want to display a dropdown list with : Sheet 1, Sheet 2 and Sheet 3
Edit : Next I want to return the value selected.