我正在尝试将我在 Google 工作表中的日程表中的日历事件设置为 Google 日历,以避免手动进行。
function scheduleShifts() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendar_ID = spreadsheet.getRange("A1").getValue();
var eventCal = CalendarApp.getCalendarById(calendar_ID);
var events = spreadsheet.getRange("H2:I996").getValues();
for (x=0; x<events.length; x++) {
var schedule = events[x];
var startTime = schedule[7];
var endTime = schedule[8];
var name = schedule[2];
var address = schedule [3];
var phone = schedule [4];
var description = schedule[5];
var comments = schedule[6];
eventCal.createEvent(address, startTime, endTime);
}
}
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Sync to Calendar')
.addItem('Schedule shifts now', 'scheduleShifts')
.addToUi();
}