我有一个使用 Google Apps 电子表格的程序,它读取数据并将数据写入电子表格,但如果电子表格中的内容发生更改,我希望 gui 自动刷新电子表格中的数据。我想用它来创建一个在一台计算机上可见的页面,然后在另一台计算机上单击一个按钮,它将增加来自另一台计算机的数量。有没有办法以谷歌应用脚本语言自动刷新网络应用标签?
var dataByDepartment = {};
var departments = [];
var dataSs = SpreadsheetApp.openById(DATA_SPREADSHEET_ID);
var dataSheet = dataSs.getSheets()[0]
var data = getRowsData(dataSheet);
function doGet() {
var app = UiApp.createApplication();
app.add(app.loadComponent("GNWDataGui"));
app.getElementById('deathLabel').setText("gameDeaths: " + data[0].deaths);
app.getElementById('killLabel').setText("gameKills: " + data[0].kills);
return app;
}
function deathClickHandler(e) {
var app = UiApp.getActiveApplication();
var sheet = dataSs.getSheetByName('General');
data[0].deaths += 1;
app.getElementById('deathLabel').setText("Death: " + data[0].deaths);
setRowsData(sheet, data);
app.close();
return app;
}
function deathClickMinHandler(e) {
var app = UiApp.getActiveApplication();
var sheet = dataSs.getSheetByName('General');
data[0].deaths -= 1;
app.getElementById('deathLabel').setText("Death: " + data[0].deaths);
setRowsData(sheet, data);
app.close();
return app;
}
function autoRefreshHandler(e) {
var app = UiApp.getActiveApplication();
app.getElementById('autoRefreshButton').setText("Auto Refresh");
data = getRowsData(dataSheet);
app.getElementById('deathLabel').setText("gameDeaths: " + data[0].deaths);
app.getElementById('killLabel').setText("gameKills: " + data[0].kills);
app.close();
return app;
}