在这里找到关于这个脚本的一些帮助。我已经调整了原始代码,但没有更改第47行。我在执行时收到此错误。 - 找不到方法createEvent(string,string,string,object)。 (第47行,文件"代码")
function exportEvents() {
var sheet = SpreadsheetApp.getActiveSheet();
var headerRows = 1; // Number of rows of header info (to skip)
var range = sheet.getDataRange();
var data = range.getValues();
var calId ="furnish.com_ksuv182d3o843go31gotmejigk@group.calendar.google.com";
var cal = CalendarApp.getCalendarById(calId);
for (i=0; i<data.length; i++) {
if (i < headerRows) continue; // Skip header row(s)
var row = data[i];
var title = row[5]; // Second column
var tstart = row[3];
var tstop = row[4];
var loc = row[8];
var desc = row[7];
var id = row[0]; // Sixth column == eventId
// Check if event already exists, update it if it does
try {
var event = cal.getEventSeriesById(id);
}
catch (e) {
// do nothing - we just want to avoid the exception when event doesn't exist
}
if (!event) {
/* cal.createEvent(title, new Date("March 3, 2010 08:00:00"), new
Date("March 3, 2010 09:00:00"), {description:desc,location:loc}); */
var newEvent = cal.createEvent(title, tstart, tstop,{description:desc,location:loc}).getId();
row[0] = newEvent; // Update the data array with event ID
}
else {
event.setTitle(title);
event.setDescription(desc);
event.setLocation(loc);
// event.setTime(tstart, tstop); // cannot setTime on eventSeries.
// ... but we CAN set recurrence!
var recurrence = CalendarApp.newRecurrence().addDailyRule().times(1);
event.setRecurrence(recurrence, tstart, tstop);
}
debugger;
}
// Record all event IDs to spreadsheet
range.setValues(data);
}
答案 0 :(得分:0)
我试试这个:
var tstart = new Date(row[3]);
var tstop = new Date(row[4]);
只是为了确保它们是日期而不是看起来像日期的字符串。