过去 3 小时我一直被这个错误困在这里。
错误异常:无法从此上下文调用 SpreadsheetApp.getUi()。
我将不胜感激的帮助。
function onOpen(e) {
var menu = SpreadsheetApp.getUi().createMenu("Refresh");//The error is here
menu.addItem("Refresh Week", "menu");
menu.addToUi();
}
Run Code Online (Sandbox Code Playgroud)
//The same thing goes to this function as well
function menu(){
//get the good week number
var date = new Date();
var wn = [(Math.floor(WEEKNUMBER(date))+3).toFixed(0)]
do {
wn.push((wn[wn.length-1]-1).toFixed(0))
} while(wn[wn.length-1] != 348);
var line = "<select style='width:60px;height:40px;' id='select'>"
for ( var x in wn )
line +="<option>" + wn[x] + "</option>"
line +="</select>"
var ui = SpreadsheetApp.getUi();
var html …Run Code Online (Sandbox Code Playgroud)