我想让谷歌工作表在谷歌日历上创建一个定期事件。
有没有办法让这部分代码依赖于电子表格中的变量?我希望能够在我的电子表格上选择一周中的几天,而不必输入它们。
.onlyOnWeekday([CalendarApp.Weekday.MONDAY,CalendarApp.Weekday.WEDNESDAY])
这是我的功能
function newStudentCalendar() {
var app = SpreadsheetApp;
var sheet = app.getActiveSpreadsheet().getActiveSheet();
var studentName = sheet.getRange(2, 1).getValue();
// set time variables for lesson creation
var year = sheet.getRange(2, 5).getValue();
var month = sheet.getRange(2, 3).getValue();
var day1 = sheet.getRange(2, 4).getValue();
var startTime = sheet.getRange(2, 6).getValue();
var endTime = sheet.getRange(2, 7).getValue();
//Creates the new students calendar
var calendar = CalendarApp.createCalendar(studentName);
Logger.log('Created the calendar "%s", with the ID "%s".',
calendar.getName(), calendar.getId());
var calendarID = calendar.getId()
//Creates the recuring lessons
var lessons = CalendarApp.getCalendarById(calendarID).createEventSeries(studentName + " lesson",
new Date(month + day1 + ',' + year + ' ' + startTime),
new Date(month + day1 + ',' + year + ' ' + endTime),
CalendarApp.newRecurrence().addWeeklyRule()
.onlyOnWeekdays([CalendarApp.Weekday.MONDAY, CalendarApp.Weekday.WEDNESDAY]));
Logger.log('Event Series ID: ' + lessons.getId());
}