我在尝试根据this教程发布我的应用脚本信息中心应用时收到错误Please select an active sheet first. (line 4, file "Code")
。我已经阅读了一些关于设置活动工作表的其他帖子,但它只会产生更多错误。我不知道如何纠正这个问题。有人可以告诉我我做错了吗?
function doGet() {
var ss = SpreadsheetApp.openById('<sheetid>');
var data = ss.getDataRange();
var ageFilter = Charts.newNumberRangeFilter().setFilterColumnIndex(1).build();
var nameFilter = Charts.newStringFilter().setFilterColumnIndex(0).build();
var genderFilter = Charts.newStringFilter().setFilterColumnIndex(2).build();
var tableChart = Charts.newTableChart()
.setDataViewDefinition(Charts.newDataViewDefinition().set([0,1,2]))
.build();
var pieChart = Charts.newPieChart()
.setDataViewDefinition(Charts.newDataViewDefinition().set([0,,2]))
.build();
var dashboard = Charts.newDashboardPanel().setDataTable(data)
.bind([ageFilter,nameFilter,genderFilter], [tableChart, pieChart])
.build();
var app = UiApp.createApplication();
var filterPanel = app.createVerticalPanel();
var chartPanel = app.createHorizontalPanel();
filterPanel.add(ageFilter).add(nameFilter).add(genderFilter).setSpacing(10);
chartPanel.add(tableChart).add(pieChart).setSpacing(10);
dashboard.add(app.createVerticalPanel().add(filterPanel).add(chartPanel));
app.add(dashboard);
return app;
}
答案 0 :(得分:1)
var ss = SpreadsheetApp.openById('<sheetid>');
var sheet = ss.getSheetByName('sheetNameHere');///////Need to get the sheet, not just the whole work book.
var data = sheet.getDataRange();