找不到函数createEvent(或createAllDayEvent)。 (Google电子表格应用程序)

时间:2018-12-17 05:41:32

标签: google-apps-script google-calendar-api spreadsheet

这是导致错误的代码。这似乎只是我尝试添加全天活动的路线。需要更改哪些内容以纠正错误,或者错误的实际含义是什么。

function SpreadsheetToCalendar3() 
{
  // This function should be executed from the 
  //  spreadsheet you want to export to the calendar
  var mySpreadsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("My Calendar-Sheet01");

  var myCalendar = CalendarApp.openByName("My Calendar-01");

  // optional - delete existing events
  var events = myCalendar.getEvents(new Date("November 1, 2018 EST"),
new Date("November 1, 2019 EST"));
  for (var i = 0; i < events.length; i++) 
  {
     events[i].deleteEvent();
  }

  var dataRange = mySpreadsheet.getRange("A2:B39");
  var data = dataRange.getValues();

  // process the data
  for (i in data) 
  {
      var row = data[i];
      // assume that each row contains a date entry and a text entry
      var theDate  = row[1];  // First column of row
      var theTitle = row[0];  // Second column of row
      myCalendar.createAllDayEvent(theTitle, theDate);
  }

}

0 个答案:

没有答案