Я очень новичок в кодировании, и я пытаюсь создать простую кнопку в Google Sheets, которая будет брать данные с вкладки ввода и заполнять последние пустые ячейки соответствующих столбцов на вкладке кормления. Я работаю над записью значений кормлений и даты, но не могу заставить их двигаться.
Вот код:
//Gets data from ‘Input’ sheet function recordData() { let src = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘Input’); //Source let dst = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘Feedings’); //Destination let input = {}; input.milk = src.getRange(‘B2’).getValue() input.formula = src.getRange(‘B3’).getValue() let today = new Date(); today.date = today.getMonth()+1+’/’+today.getDate(); today.formatTime = function formatAMPM (time) { var hours = time.getHours(); var minutes = time.getMinutes(); var ampm = hours >= 12 ? ‘pm’ : ‘am’; hours = hours % 12; hours = hours ? hours : 12; // the hour ‘0’ should be ’12’ minutes = minutes < 10 ? ‘0’+minutes : minutes; var endTime = hours + «:» + minutes + » «+ ampm; return endTime; } today.time = today.formatTime (new Date); Logger.log(«formula = » + input.formula); Logger.log(«milk = » + input.milk); Logger.log(«date = «+ today.date); Logger.log(«time = «+ today.time); //moves data from ‘Input’ to ‘Feeding’ sheet. **NOT WORKING** function moveData () { var dstFeedings = {}; dstFeedings.date = dst.getRange(«Feedings!A2:A»).getLastrow.setValues(today.date); dstFeedings.time = dst.getRange(«Feedings!B2:B»).getLastRow.setValues(today.time); dstFeedings.formula = dst.getRange(«Feedings!C2:C»).getLastRow.setValues(input.formula); dstFeedings.milk = dst.getRange(«Feedings!D2:D»).getLastRow.setValues(input.milk); return dstFeedings; } }
Вот ссылка на копию таблицы
Источник: