google apps script - Typo error: Cannot call method "getDataRange" of null -
im trying publish code, everytime when run code error cannot call method"getdatarange" of null. please me sort out .here code function
doget() { var ss = spreadsheetapp.openbyid('sheet id'); var sheet = ss.getsheetbyname('sheet name'); var data = sheet.getdatarange(); var datefilter= charts.newcategoryfilter().setfiltercolumnindex(0).build(); var agefilter = charts.newnumberrangefilter().setfiltercolumnindex(7).build(); var transportfilter = charts.newcategoryfilter().setfiltercolumnindex(2).build(); var namefilter = charts.newstringfilter().setfiltercolumnindex(1).build(); var tablechart = charts.newtablechart().setdimensions(700, 300) .setdataviewdefinition(charts.newdataviewdefinition().setcolumns([0,1,2,3,4,5,6,7])) .build(); var piechart = charts.newpiechart() .setdataviewdefinition(charts.newdataviewdefinition() .setcolumns([1,7])).build(); var dashboard = charts.newdashboardpanel().setdatatable(data) .bind([datefilter,agefilter, transportfilter, namefilter], [tablechart, piechart]) .build(); var app = uiapp.createapplication().setheight(50); var todaysdate = new date(); app.add(app.createlabel(todaysdate)); app.add(app.createhtml('<h1 style="text-align:center;">demo</h1>')); var filterpanel = app.createhorizontalpanel(); var chartpanel = app.createhorizontalpanel(); filterpanel.add(datefilter).add(agefilter).add(transportfilter).add(namefilter).setspacing(10); chartpanel.add(tablechart).add(piechart).setspacing(50); dashboard.add(app.createverticalpanel().add(filterpanel).add(chartpanel)); app.add(dashboard); var service = scriptapp.getservice(); service.enable(service.restriction.all); return app; }
the error indicate sheet
null. make sure using correct sheet name in var sheet = ss.getsheetbyname('sheet name');
. copy , paste sheet name google doc if there invisible characters.
Comments
Post a Comment