Created
December 27, 2010 12:01
-
-
Save wkrsz/756086 to your computer and use it in GitHub Desktop.
Google App Script - import calendar events into a spreadsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function import_calendar( start_date, end_date, cal_name, spreadsheet, sheet_name) { | |
var sheet = spreadsheet.getSheetByName(sheet_name); | |
var cal = CalendarApp.getCalendarsByName(cal_name)[0]; | |
sheet.clear(); | |
events = cal.getEvents( start_date, end_date ); | |
irow = 2; | |
for( i in events ) { | |
evt = events[i]; | |
var date = evt.getStartTime(); | |
var formatted_date = (date.getMonth()+1) + '/' + date.getDate() + '/' + date.getYear(); | |
sheet.getRange("A"+irow).setValue( formatted_date ); | |
sheet.getRange("B"+irow).setValue( evt.getTitle() ); | |
irow ++; | |
} | |
} | |
function import_calendars() { | |
var start_date = new Date("Jan 1, 2010"); | |
var end_date = new Date("Jan 1, 2011"); | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
import_calendar( start_date, end_date, "holidays", ss, "holidays" ); | |
import_calendar( start_date, end_date, "days off - Daniel", ss, "days off - Daniel" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey,
I've dnoe something similar that imports the coming 200 days worth of events into the spreadsheet