【发布时间】:2014-01-08 03:10:56
【问题描述】:
我是 Javascript 编程的新手,所以这对我来说是一项艰巨的任务 - 但我觉得我可以在一些帮助和指导下完成 - 我通常使用 vb、vba、c# 进行编程。
所以无论如何,我的工作同事问我是否可以制作一些基本上可以告诉他们谁在度假/今天有半天的东西-目前我已经可以发送电子邮件-但是在阅读单元格时和行..我一无所知,这就是我卡住的地方。
这是我的电子表格
https://docs.google.com/spreadsheet/ccc?key=0Ao7GdcoXMWiHdDNxY1k2X1hyYkhkQ210QldBeHZqaFE&usp=sharing
摘要只是所有工作表的整体视图 - 它显示某人在逐月快速视图中的假期/半天/病假天数。 这是通过使用键 H - 假期、BH - 银行持有日、HD - 半天、S - 病假、HS - 半病假和月份标签中的缺勤来更新的。
现在开始我想要实现的目标。假设今天是 2012 年 12 月 20 日,比尔鲍勃今天在度假 - 我想发送一封电子邮件,说明这一点 - 目前我有一个电子邮件正文设置发送,这有效(有点,消息正文只是缺少谁正在度假,谁在半天)-我将如何获取此信息-我知道我需要获取今天的日期,然后检查该月并检查 H 或 HD 的列,然后再检查该行以找出谁然后在编译列表以添加到消息之前将其存储在某个变量中。
我该怎么做呢?
// Variables for the Date
var today = new Date();
var dd = today.getDate(); // Get todays date
var mm = today.getMonth()+1; // Get todays month - January is 0!
// Variables for the email
var sendEmail = false;
var emailAddress = "";
var subject = "Daily Holiday Summary";
var messagePT1 = "Good Morning,\n\nThe following people have half a day today\n\n";
var messagePT2;
var messagePT3 = "\n\nThe following people are on holiday today\n\n";
var messagePT4;
var messagePT5 = "\n\nMany thanks,\nThe Holiday Spreadsheet";
var fullMessage;
// Variables for the sheets
var sheet = SpreadsheetApp.getActiveSpreadsheet();
sheet.setActiveSheet(sheet.getSheets()[0]);
function main() {
// This is the main function and will be the one that is ran
findMessagePT2();
findMessagePT4();
sendEmail();
}
function findMessagePT2() {
// This is the function for finding the people on half a day today
}
function findMessagePT4() {
// This is the function for finding the people on holiday today
}
function sendEmail() {
// This is the send email function and will send the email
if (sendEmail == true){
fullMessage = messagePT1 + messagePT2 + messagePT3 + messagePT4 + messagePT5;
MailApp.sendEmail(emailAddress, subject, fullMessage);
}
}
这是我目前拥有的代码,如果我找不到任何正在度假或半天的人,我不希望发送消息 - 好像有人在我确实希望发送消息,因此sendEmail 函数中的 if 语句。
【问题讨论】:
标签: javascript google-apps-script row google-sheets google-spreadsheet-api