Create Calendar Events in Google Calendar using the Calendar API and Google Apps Script.

Step 1 : Sample Google Sheet

  1. Name of the Event
  2. Start date/time of the Event
  3. End date/time of the Event
  4. Location of the Event
  5. Description of the Event

Step 2 : Add the Google Calendar API

  1. To add the Google Calendar API, follow these steps:
    Open the Script Editor. To open the Script Editor, follow these steps :

    (1) Click on the Tools button next to the Add-ons button.

Step 3 : Write the Automation Script

function create_Events(){(1) var ss = SpreadsheetApp.getActiveSpreadsheet();
(2) var sheet = ss.getSheetByName("Calendar_Events");
(3) var last_row = sheet.getLastRow();
(4) var data = sheet.getRange("A1:E" + last_row).getValues();
  1. Get the Active Spreadsheet
  2. Get the sheet by name
  3. Get the Last row of the sheet
  4. Get the range followed by getting the values for the range
(1) for(var i = 0;i< data.length;i++){(2)var event = CalendarApp.getDefaultCalendar().createEvent(data[i][0],          (3) new Date(data[i][1]),(4) new Date(data[i][2]),{location: data[i][3]});
  1. First we have created a for loop in so that we can go through each event and add the details to the calendar.
  2. Next we are going to create a variable called event where we are going to create events using the CalendarApp command.
 Logger.log("Events have been added to the calendar");}

Step 3 : Check the Output


  1. Added all the events into the sheet [Title, Start Time, End Time, Location and description of the event]
  2. Accessed the sheet by name
  3. Got the last row
  4. Got the range and the values
  5. Created a for loop to go through each event in the sheet
  6. Used the Calendar App command and created the events in the Google Calendar.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aryan Irani

Aryan Irani

Currently pursuing B Tech at MPSTME. Technical Blogger, interested in Google Workspace. Hope to remain a life long student.