I'm writing my 1st google app script. Spreadsheet opens a sidebar in onOpen()
. Sidebar has Button and in SidebarJavaScript.html I have listener to that button. I'm calling SpreadsheetApp.getActiveSpreadsheet()
inside listener and after this line script is not executing.
What could possibly be wrong here?
function onScrapeClick(){
// Disable Button
this.disabled = true;
// Get Spreadsheet
var sheet = SpreadsheetApp.getActiveSpreadsheet();
this.innerHTML ="Clicked";
var data = sheet.getDataRange().getValues();
}
Button is getting disabled as for line this.disabled = true;
as expected so lister is working properly for sure.
getValues is a method of the sheet class, you just need to define the active sheet
You must define the method to get data in a
.gs
file and call it withgoogle.script.run
.In some
Code.gs
file:And in the html script: