I've been using this script to pull Data from Google Calendar into a spreadsheet. I have a couple questions for improvements:
- Is it possible to have this pull data from multiple calendars to the same spreadsheet without them overwriting each other?
- Is it possible to have it add a new column of data to the spreadsheet that marks which calendar each row came from?
- Also, how would you go about setting this up to run automatically every 24 hours?
THANKS!
function caltest3(){
var ss = SpreadsheetApp.openById("SPREADSHEET ID");
SpreadsheetApp.setActiveSpreadsheet(ss);
var cal=CalendarApp.getCalendarById("CALENDAR ID");
var sheet = SpreadsheetApp.getActiveSheet();
var events = cal.getEvents(new Date("January 1, 2013"), new Date("January 13, 2013"));
for (var i=0;i<events.length;i++) {
//http://www.google.com/google-d-s/scripts/class_calendarevent.html
var details=[[events[i].getTitle(), events[i].getStartTime(),
events[i].getEndTime(), events[i].getDescription(),
events[i].getLocation()]];
var row=i+1;
var range=sheet.getRange(row+1,1,1,5);
range.setValues(details);
}
}
}