我对此很陌生,在尝试在当前Google表格上运行此功能时,找不到适合我的解决方案。我继续收到错误消息:“请先选择一个活动的表格” ,但是我已将目标定位在下面的函数中,对吗?如果有人能对我做错了什么有深刻的了解,将不胜感激。
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu("MAH MENU").addItem("TEST", "crawlOnEm").addToUi();
}
function crawlOnEm() {
var ui = SpreadsheetApp.getUi();
var activeSheet = SpreadsheetApp.getActiveSpreadsheet();
var selection = activeSheet.getSelection().getCurrentCell();
var row = selection.getRow();
var column = selection.getColumn();
var sheetWeCareAbout = activeSheet.getSheetByName("Week-by-week");
var walkingRange = sheetWeCareAbout.getRange(row, 1);
var walkingRow = row;
while(walkingRange.getBackground() !== "#efefef" && walkingRow >= 1) {
walkingRange = sheetWeCareAbout.getRange(walkingRow, 1);
walkingRow++;
}
ui.alert("Date is: " + walkingRange.getValue());
}
答案 0 :(得分:0)
activeSheet.getSheetByName("Week-by-week")
很可能返回null
。仔细检查是否存在名为Week-by-week
的工作表。