編輯:這個問題讓我被禁止提問......我做錯了什么?!我真的不明白。
編輯:解決方案這需要是一個 onEdit() 函式。謝謝@cooper。
我把頭撞在鍵盤上。請幫忙。
這似乎應該很簡單......但我繼續收到錯誤:
TypeError:無法讀取 onChange 處未定義的屬性“getNumColumns”(復選框:5:20)
目標是單擊一個復選框,獲取一個日期戳,但我還需要檢查列標題(第 4 行)以確定接下來要運行的函式......但是,我無法做到這一點,因為我需要知道觸發該功能的單元格的列。
function onChange(e) {
const range = e.range;
Logger.log(range.getNumColumns());
};
/**Trigger:
Head:= Deployment
Event:= From spreadsheet - On change
Function:= onChange
Error rate:= 100% */
從技術上講,我可以使用activecell,但我擔心用戶不可靠,如果他們選中 col:1 中的復選框然后單擊 col:2,會activecell回傳 col:1 還是 2,會發生什么?
我嘗試了多種組合來解決這個問題,但每次都說“無法讀取未定義的屬性'getNumColumns'”
我嘗試了以下方法:
e.range.columnStart
uj5u.com熱心網友回復:
function onEdit(e) {
e.range is the location of the edit it could be more than one cell if it's something like a paste.
e.range.getSheet() is the sheet
e.range.columnStart is the column of the edited cell
e.range.rowStart is the row of the edited cell
e.range.columnEnd is the last column in e.range
e.range.rowEnd is the last row in e.range
e.source is the active spreadsheet
e.oldValue is the value before the change
e.value is the value after the edit
Logger.log(JSON.stringify(e)); //will provide a description of the entire event object
}
有時還有其他的,例如授權級別和用戶資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/452941.html
