function testSchemas() {
var htmlout = HtmlService.createTemplateFromFile('data').evaluate().getContent();
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('All Exams Tracker');
var range = sheet.getDataRange();
var values = range.getValues();
var last_row = sheet.getLastRow();
var today = new Date()
for (var i =3 ;i < last_row;i++) {
var temp = values[i][4];
var e_date = new Date(temp);
if (((e_date - today)/(1000*60*60*24)) < 10 && e_date > today){
var cond = "done" }
break; }
Logger.log(cond);
if (cond == "done"){
MailAppv.sendEmail({
to: '*************************************************************',
subject: 'Exam Coming Next Week',
htmlBody: htmlout,
});
}}
觸發時,這將HTML文件數據(如下)。
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
}
</style>
</head>
<table style = "border: 1px solid black; border-style: collapse;">
<? var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('All Exams Tracker');
var range = sheet.getDataRange();
var values = range.getValues();
var last_row = sheet.getLastRow();
var today = new Date();?>
<tr style="border: 1px solid black; padding: 10px;">
<th style="border: 1px solid black; padding: 10px;">Exam Name</th>
<th style="border: 1px solid black; padding: 10px;">Exam Date</th>
<th style="border: 1px solid black; padding: 10px;">Priority</th>
<th style="border: 1px solid black; padding: 10px;">College Predictor Status</th>
<th style="border: 1px solid black; padding: 10px;">Rank Predictor Status</th>
</tr>
<? for (var i =3 ;i < last_row;i++) {
var temp = values[i][4];
var e_date = new Date(temp);
if (((e_date - today)/(1000*60*60*24)) < 10 && e_date > today) {
if (values[i][12] != ""){
var col_status = "Live"}
else
if (values[i][11] != ""){
col_status = "Uploaded and Tested"}
else
if (values[i][10] != ""){
col_status = "Data Processed"}
else
if (values[i][9] != ""){
col_status = "Template Ready"}
else
col_status = "Not initiated yet"
if (values[i][19] != ""){
var rank_status = "Live"}
else
if (values[i][18] != ""){
rank_status = "Uploaded and Tested"}
else
if (values[i][17] != ""){
rank_status = "Data Processed"}
else
rank_status = "Not Initiated yet"
?>
<tr>
<td style="border: 1px solid black; padding: 10px;"><?= values[i][2]?></td>
<td style="border: 1px solid black; padding: 10px;"><?= values[i][4]?></td>
<td style="border: 1px solid black; padding: 10px;"><?= values[i][8]?></td>
<td style="border: 1px solid black; padding: 10px;"><?= col_status?></td>
<td style="border: 1px solid black; padding: 10px;"><?= rank_status?></td>
</tr>
<? } }?>
</table>
<br><br>
<p><a href="https://docs.google.com/spreadsheets/d/1fzbRCvnNfuVTCEuRnncJxb1VW7f-tkSEywntzaTugZQ/edit#gid=0">Click Here For More Details</a></p>
</html>
菲爾我似乎無法得到它用這個腳本觸發,它可能是我做錯了什麼? 這是表格。我已經嘗試了各種方法,例如使用另一個工作表來測量第一個使用EQ操作符的值,然後測試TRUE。 [鏈接] https://docs.google.com/spreadsheet/ccc?key=0Ai_2YLvaQba0dGtCbFdmeDF6bHNaY0p5NnNOemZtcXc&usp=sharing [/鏈接]我有 但有一個問題是,當我導入數據從一個片到另一個式變化在表單輸入發生時在第二張表上? –
您正在尋找的觸發器是onFormSubmit()。 –
我把代碼應該看起來像[這裏](http://pastebin.com/Bm8qX2af)。當您提交表單時,它將添加到最後一行,因此檢索單元格(最後一行,B列)。如果它等於6,則發送電子郵件。 –