我正在制作一個 Google 表格,用于跟蹤打卡時間。我想添加一個列 e,它將計算給定開始時間(c 列)和結束時間(d 列)的工作小時數。我該如何實施呢?這是我的代碼:function setValue(cellName, value){ SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).setValue(value);}function getValue(cellName){ return SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).getValue();}function getNextRow(){ return getCurrentRow() + 1;}function getCurrentRow(){ return SpreadsheetApp.getActiveSpreadsheet().getLastRow();}function addStart(a, b, c, d){ var row = getNextRow(); setValue('A' + row, a); // employee name row setValue('B' + row, b); // date row setValue('C' + row, c); // clock in time row}function addEnd(endTime) { var row = getCurrentRow(); setValue('D' + row, endTime); // }function updateRow(e){ // declare row e var row = getCurrentRow(); setValue('E' + row, e) }function punchIn(){ addStart("Faiq Ashraf", new Date(), date(), "")}function punchOut(){ addEnd(date());}function totalHours(){ // function used to update column e with our total hours worked var total = getCurrentRow().addEnd(d) - getCurrentRow().addStart(c) updateRow(total);}function date(){ var dd = new Date(); var currentTime = dd.toLocaleTimeString(); return currentTime}javascript谷歌應用腳本谷歌表格
從當前行單元格中減去兩個值并將該值輸出到新的單元格行(谷歌腳本)
qq_遁去的一_1
2022-11-11 14:54:52