获取活动标题并在电子表格中显示

时间:2014-12-09 13:22:25

标签: google-apps-script google-sheets

大家好我想在下周展示所有活动标题你能否帮助我仍然有错误

function getevents() {


var sheet = mySpread.getActiveSheet();
 var now = new Date();
 var oneWeekFromNow = new Date(now.getTime() + (7 * 24 * 60  *60 * 1000));
 var events = CalendarApp.getDefaultCalendar().getEvents(now, oneWeekFromNow).getTitle();
 var myEvents = [];
     for (var i = 0; i < events.length; i++) {
       var tableauEvents = [];

   tableauEvents.push(events[i].getEvents(now, oneWeekFromNow))
   myEvents.push(tableauEvents);
   sheet.getRange(2, 2, myEvents.length, myEvents[0].length).setValues(myEvents)
   SpreadsheetApp.flush()

 }

}

1 个答案:

答案 0 :(得分:0)

如果有人需要

,这就是结果
function getevents() {
var cal = CalendarApp.getDefaultCalendar(); 
var sheet = SpreadsheetApp.getActiveSheet();
var now = new Date();
var oneWeekFromNow = new Date(now.getTime() + (7 * 24 * 60  *60 * 1000));
var events = cal.getEvents(now, oneWeekFromNow);
 var myEvents = [];
     for (var i = 0; i < events.length; i++) {
       var tableauEvents = [];

       tableauEvents.push(events[i].getTitle())
       myEvents.push(tableauEvents);
       sheet.getRange(2, 2, myEvents.length, myEvents[0].length).setValues(myEvents)
       SpreadsheetApp.flush()

     }  
}