【发布时间】:2018-12-05 10:12:40
【问题描述】:
我有一个脚本,它在 Google 表格中的每日触发器上运行,从一个电子表格中提取数据并将其存储在另一个电子表格中。
它运行良好,但我需要它不要在周日运行。我不太清楚如何验证日期,只在周一至周六运行脚本。
function copyDailyreport() {
var timeStamp=Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "MM/dd/yyyy");
var sheetFrom = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("MSM");
var sheetTo = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("MSM Daily Totals");
var valuesToCopy = sheetFrom.getRange(4, 11, sheetFrom.getLastRow(), 1).getValues();
//convert the column to a row
valuesToCopy=valuesToCopy.join('*#*');
valuesToCopy=valuesToCopy.split('*#*');
//add timestamp in the first place in the row
valuesToCopy.unshift(timeStamp)
//add the row to destination sheet
sheetTo.appendRow(valuesToCopy);
var timeStamp=Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "MM/dd/yyyy");
var sheetFrom = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SM");
var sheetTo = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SM Daily Totals");
var valuesToCopy = sheetFrom.getRange(4, 11, sheetFrom.getLastRow(), 1).getValues();
//convert the column to a row
valuesToCopy=valuesToCopy.join('*#*');
valuesToCopy=valuesToCopy.split('*#*');
//add timestamp in the first place in the row
valuesToCopy.unshift(timeStamp)
//add the row to destination sheet
sheetTo.appendRow(valuesToCopy);
var timeStamp=Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "MM/dd/yyyy");
var sheetFrom = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SH");
var sheetTo = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SH Daily Totals");
var valuesToCopy = sheetFrom.getRange(4, 11, sheetFrom.getLastRow(), 1).getValues();
//convert the column to a row
valuesToCopy=valuesToCopy.join('*#*');
valuesToCopy=valuesToCopy.split('*#*');
//add timestamp in the first place in the row
valuesToCopy.unshift(timeStamp)
//add the row to destination sheet
sheetTo.appendRow(valuesToCopy);
}
谢谢!
【问题讨论】:
-
谢谢,我会通读所有这些!