function nextI() {
var ps=PropertiesService.getScriptProperties();
if(!ps.getProperty('curI')) {//if it doesn't exist
ps.setProperty('curI', 0);//create it and set it to zero
SpreadsheetApp.getUi().alert(ps.getProperty('curI'));//Display it
}else{
ps.setProperty('curI', Number(ps.getProperty('curI'))+1);//if it exists then increment it
SpreadsheetApp.getUi().alert(ps.getProperty('curI'));//display it
}
}
function counter(){
PSd = PropertiesService.getDocumentProperties();
var n = PSd.getProperty('count');
n++
PSd.setProperty('count', n);
Browser.msgBox(n,Browser.Buttons.OK);
}
2条答案
按热度按时间yshpjwxd1#
Google Apps脚本中的简单计数器
这作为电子表格绑定脚本运行。
PropertiesService
UI Class
Spreadsheet App Class
egmofgnx2#
一个简单的方法:
不需要创造条件,他创造和增加价值,不需要任何"考验"