作爲免責聲明,我對編程概念頗爲陌生。如果你真的想成爲我最好的朋友,那麼解釋越具體越好。但任何幫助表示讚賞。使用腳本應用從Google表格中的單元格拉取日期
我的小型企業使用QuickBooks進行工資計時,但出於後勤目的,我們的員工使用谷歌電子表格輸入他們的時間。
我想寫一個腳本,每天檢查第一列的日期兩次(按照我設置的觸發器)。如果日期等於或大於今天的日期,我需要腳本檢查同一行中幾列的單元格以查看單元格是否已被填寫。如果它是0或null,我想發送一個通知。
請參閱下圖以供參考。
到目前爲止,這是我所:
function values2()
{
var ss = SpreadsheetApp.getActiveSpreadsheet(),
sheet = ss.getSheetByName("TimeSheet"),
range = sheet.getDataRange(),
values = range.getValues(),
indx, logToday, today, body,
recipients = "[email protected]",
subject = "Timesheet Notification" + ss.getName();
//Finds current date and creates string. I would prefer to have a numeric value associated to the current date, as well as a numeric value associated with the date for each row.
var CurrentDate = new Date();
Logger.log(CurrentDate);
logToday = Logger.getLog();
indx = logToday.indexOf("INFO");
today = logToday.substring(indx + 6, indx + 16);
//I'm having things sent to my email for test purposes
MailApp.sendEmail(recipients, subject, today);
//Clears Log
Logger.clear();
for (var r=1; r<values.length; r++)
{
var row = values[r],
date = row[0],
price = row[1],
units = row[2],
total = row[3],
name = row[4];
Logger.log(date);
Logger.log(price);
Logger.log(units),
Logger.log(total),
Logger.log(name);
}
body = Logger.getLog();
MailApp.sendEmail(recipients, subject, body);
}
在這一點上,我希望能夠趕上從第一列每個日期,將其比作今天的日期,支票另一個單元格放在同一行中,然後移至第一列中的下一個日期。我已經玩過IF/Else的聲明,但無濟於事。
向我們展示您的嘗試和出錯 –