Back to Blog

Tutorial on How You Can Export Google Calendar to Google Sheets with and without Coding

Google Calendar is widely known as one of the best tools to manage schedules and tasks. It captures your work and meetings that take both short and long periods of time. It has become a data source containing useful information about your work life. In some cases, you may need to export your calendar data to Google Sheets. But what method should you use? Find the answer in this blog post. 

Why you would need to export data from your Google Calendar to Sheets

You may need a list of activities and the time spent on each of them, for purposes such as:

  • Sending invoices to clients, especially for services you charge on an hourly basis.
  • Creating reports for administrative purposes. 
  • Analyzing your productivity or your teams’. For example, to know whether you spend too much time on certain types of tasks, or if you work on high-priority tasks first, etc.

Google Calendar has the data you need. You could click on each individual event on your Calendar to get the hours you spent on each activity. However, having your data exported to Google Sheets in a more automatic way will always be a better solution. It saves you time and minimizes errors. It’s also easier doing basic data analysis in a spreadsheet, such as summing the hours and sorting the activities.

Can I export Google Calendar to a spreadsheet with native functionality?

Unfortunately, currently, there’s no such functionality within Google Calendar that allows you to export data directly into Google Sheets. What you can do is export the ICS file of an individual Calendar. 

An ICS file is a standard Internet calendar format that stores calendar event data. It’s used by several calendar programs, including Microsoft Outlook, Google Calendar, Yahoo! Calendar, and Apple Calendar. With ICS format, you can share your calendar data with someone else who’s using a program other than Google Calendar.

Follow the steps below if you’d like to export ICS files from all of your calendars associated with your Google account.

Open Google Calendar. In the top right, click the Settings icon, then click Settings from the menu. 

On the Settings page, click the Import & export > Export menu. Then, under the Export section, click the Export button. 

You’ll see a ZIP file download to your computer. Unzip it, and you’ll find individual ICS files for each of your calendars.

Now, you can share these ICS files (or one of them) with your friend. They should be able to open it using their calendar program – Outlook, Yahoo! Calendar, or Apple Calendar.

How to export Google Calendar to Google Sheets using add-ons

The most actionable way to transfer calendar data to Google Sheets is by using a Google Sheets add-on. There are a few options that allow you to get data from Calendar, such as Calendar to Sheet and Sheets2GCal.

GSheets add-ons are third-party software applications. You can view the add-on library by clicking Add-ons > Get add-ons from the top menu. It will open a new dialog window that allows you to browse or search for a particular add-on. Alternatively, you can go directly to Google Workspace Marketplace and search for the options right there.

Clicking on each add-on will bring up a description of what it does. To install it, click the Install button. It will ask permission to access your Google Drive, and you need to allow it to complete the installation.

Export calendar data with the Calendar to Sheet add-on

Calendar to Sheet allows you to import your Google Calendar events into Google Sheets by applying date and text filters. After installing the add-on, you will see it in the Add-ons menu.

Before importing data, you need to specify which calendars you want to import. You can also add text and date filters. 

Here is an example result of importing calendar data with Calendar to Sheet:

See that you have event data such as start time, end time, event description, duration, notes, and location exported in the spreadsheet. Info about the total duration is also displayed at the top of the page.

Export calendar data with the Sheets2GCal add-on

Sheets2GCal not only allows you to import Google Calendar events into Google Sheets but also update Calendar from Sheets. To get started after installing, click Add-ons > Sheets2GCal > Import (Calendar->Sheet) menu to import data from Google Calendar. 

You will need to specify which Calendar you want to import. You can also set the Start Date and End Date if you want to. However, before you can import, you need to sign up for a FREE account on sheets2gcal.com. 

Click the Import Events button, and you will get a result similar to this below. 

Notice that the result has more fields compared to the result of Calendar to Sheet. However, it doesn’t have a column that shows duration, so you need to calculate it yourself. Here’s how you can do this:

Step 1. Insert a new Duration (hh:mm) column after the End Time column.

Step 2. Enter this formula into a blank cell under the new column.

=G2-F2

Step 3. Apply the formula to the other cells by selecting the formula cell and then dragging the fill handle down to the other cells. 

If your data set is large enough, you’d be better off using the ARRAYFORMULA function instead of dragging the formula. Here is how it will look:

=ARRAYFORMULA(IF(len(G2:G)>0,(G2:G-F2:F),""))

Is auto-export Google Calendar to Google Sheets available with add-ons? 

None of the options above allow you to export data from Calendar automatically. So, you won’t be able to schedule reports on a daily or weekly basis. Such a feature is available at Coupler.io, a solution for importing data to Google Sheets from different sources such as Airtable, Shopify, HubSpot, BigQuery, and many others. Coupler.io supports time-tracking tools such as Clockify and Harvest, but Google Calendar is not supported yet.

If you need to auto-export Google Calendar to spreadsheets on a schedule, fill out this form and let the Coupler.io team know about this. We are constantly working on new importers and care about the needs of our customers. 

Other options for you to export information from Google Calendar to spreadsheet without coding

Of the many SaaS tools that can help you export Google Calendar to spreadsheets automatically, we decided to introduce TimeTackle. It was originally a simple calendar exporter called Gcal2Excel. Now, they have expanded the list of the features and sources, so you can consider it for your needs if you want to save time doing advanced analytics, generating invoices, creating many custom reports, and exporting automatically as scheduled.

What TimeTackle can do:

  • Export Google Calendar to Excel, PDF, CSV, HTML, and OpenDocument
  • Sync Google Calendar to Google Sheets and schedule automatic export
  • Export with color options (calendar color or event color)
  • Create invoices automatically from calendar entries
  • Generate many types of custom reports
  • Provide advanced calendar analytics features

Once you’ve signed up, you need to log in and select the Exporter menu listed at the top. Tick the Calendar(s) you want to export, then select the date range for your export.

Preview your export by clicking the Preview and Download button at the bottom of the page. 

The following page will open and display how the exported data will look:

You can choose the file format you want and download it to your computer or Google Drive. After that, you can import your calendar data to Google Sheets manually. Or you can sync it directly with Google Sheets!

How to export Google Calendar to Sheets using Google App Script

Above we introduced the no-code solutions. Now, let’s explore how you can export calendar data using Google App Script. 

No need to worry even if this is your first script. We have provided the copy-and-paste solution for you, so you won’t have to code on your own.

Export Google Calendar events to Google Sheets using App Script

Before you start, you will need to get the ID of your Calendar. 

How to get the Calendar ID:

Open Google Calendar, then click the Settings icon > Settings at the top right. On the Settings page, scroll down to the Calendar you want to export. Select Integrate calendar from the left menu. Then, copy the value of Calendar ID displayed in the right pane, as the following screenshot shows.

Note: You can also simply use your Google email address as the Calendar ID if you want. In that case, all your calendars will be exported.

Now, follow the easy step-by-step below:

Step 1. Create a new blank Google Sheets document. Give it a name – for example, Google Calendar Import.

Step 2. Copy and paste your Calendar ID into the B1 cell.

Step 3. Specify the criteria to filter the calendar data:

  • Start date (B2 cell) in the format mm/dd/yyyy hh:mm:ss
  • End date (B3 cell) in the format mm/dd/yyyy hh:mm:ss
  • Text to search (B4 cell)

Note: Start date and End date values must be formatted as Date Time

Step 4. From the menu, click Tools > Script editor.

Step 5. Remove all code in Code.gs. Then, copy and paste the following importGoogleCalendar() function into the file:

function importGoogleCalendar() { 
  var sheet = SpreadsheetApp.getActiveSheet();
  var calendarId = sheet.getRange('B1').getValue().toString(); 
  var calendar = CalendarApp.getCalendarById(calendarId);
 
  // Set filters
  var startDate = sheet.getRange('B2').getValue();
  var endDate = sheet.getRange('B3').getValue();
  var searchText = sheet.getRange('B4').getValue();
 
  // Print header
  var header = [["Title", "Description", "Start", "End", "Duration"]];
  var range = sheet.getRange("A6:E6");
  range.setValues(header);
  range.setFontWeight("bold")
 
  // Get events based on filters
  var events = (searchText == '') ? calendar.getEvents(startDate, endDate) : calendar.getEvents(startDate, endDate, {search: searchText});
 
  // Display events 
  for (var i=0; i<events.length; i++) {
    var row = i+7;
    
    var details = [[events[i].getTitle(), events[i].getDescription(), events[i].getStartTime(), events[i].getEndTime(), '']];
    
    range = sheet.getRange(row,1,1,5);
    range.setValues(details);
 
    // Format the Start and End columns
    var cell = sheet.getRange(row, 3);
    cell.setNumberFormat('mm/dd/yyyy hh:mm');
    cell = sheet.getRange(row, 4);
    cell.setNumberFormat('mm/dd/yyyy hh:mm');
 
    // Fill the Duration column
    cell = sheet.getRange(row, 5);
    cell.setFormula('=(HOUR(D' + row + ')+(MINUTE(D' +row+ ')/60))-(HOUR(C' +row+ ')+(MINUTE(C' +row+ ')/60))');
    cell.setNumberFormat('0.00');
  }
}

Note: Alternatively, you can set up filters right in the script:

  // Set filters
  var startDate = new Date("December 1, 2020 00:00:00");
  var endDate = new Date("December 31, 2020 23:59:59");
  var searchText = 'Dev';

If you don’t want to apply a text filter, set the value of seachText to an empty string, as follows:

var searchText = '';

Step 6. Run the script from the Editor

Note: The very first time you run the script, you will be asked to authorize the script to access your data. Grant permission when requested.

Here’s the output:

From the screenshot above, see that the script exports each event’s title, description, start time, end time, and duration. If you’d like to export more data such as event color, location, and attendance, this method list can help you.

Set up a button to export Google Calendar to Google Sheets

It’s not always convenient to run the script from the Editor. Thus, let’s tweak the script a bit, so you can run it right from the spreadsheet.

Add the following function to the Code.gs file.

function onOpen() {
  "use strict";
  var menuEntries = [{
    name: "Import",
    functionName: 'importGoogleCalendar'
  }], activeSheet;
  
  activeSheet = SpreadsheetApp.getActiveSpreadsheet();
  activeSheet.addMenu('Import Calendar', menuEntries);
}

Now your script has two functions, onOpen() and importGoogleCalendar(), as the following screenshot shows:

The onOpen() function adds a custom menu Import Calendar every time you open the spreadsheet. It has the Import sub-menu that calls the importGoogleCalendar() function.

Save the script, then refresh your spreadsheet. You will see a new menu added to your spreadsheet.

Now, every time you want to export data from the Calendar, just click the Import Calendar > Import menu. 

Set up auto-export Google Calendar to Google Sheets with Apps Script

If you don’t want to click the Import Calendar button every time, you can schedule the export of data from Google Calendar to Google Sheets. To do this, you’ll need to set up a time-drive trigger. Go to the Triggers section in your Apps Script project.

Then click + Add Trigger in the bottom right of the window.

In the new window, you’ll need to set up the trigger.

Choose which function to run

Select the function you want to automate on a schedule. Since we have two functions, onOpen() and importGoogleCalendar(), we need to choose the one that imports data from Google Calendar to the spreadsheet.

Choose which deployment should run

Select the deployment if you have different ones.

Select event source

Select the event source: from spreadsheet, time-driver or from calendar. In our case, we need time-driven.

Select type of time based trigger

Once you selected the time-driven event source, the next field is to choose the type of time-based trigger:

  • Specific date and time
  • Minutes timer
  • Hour timer
  • Day timer
  • Week timer
  • Month timer

We want to import data from Calendar on a daily basis. So, we need to choose Day timer.

Select time of day

Select the time when you want the data to be imported every day.

Failure notification settings

You can select the frequency of getting notifications in the case of failure:

  • Immediately
  • Hourly
  • Daily
  • Weekly 

If you click on the plus symbol, you can set up multiple notifications.

When ready, click Save. Your time-based trigger will appear on the list.

Bonus: from Google Sheets to Google Calendar

Suppose you worked during a vacation and simply logged your activities in a spreadsheet. To keep track of your schedules, you can automatically export your entries to Google Calendar. The following example shows you how to do that using a script.

Export dates in Google Sheets to Calendar 

Before you jump into the code, ensure that the dates in your spreadsheet are in the correct format to make it easier to export. 

Select the dates, then click Format > Number > Date Time from the menu. 

Now, you’re ready to export to Google Calendar. 

Google App Script to export from a Sheet to Calendar 

Follow the steps below to create the script.

Step 1. Click Tools > Script editor.

Step 2. Remove all code in Code.gs file. Then, copy and paste the following code.

function exportToCalendar() {
  var calendarId = "jl9l4jg8q4jdjg1qo3o202rj4c@group.calendar.google.com"; 
  var calendar = CalendarApp.getCalendarById(calendarId);
 
  var sheet = SpreadsheetApp.getActiveSheet();
 
  var events = sheet.getRange("A2:C3").getValues();
 
  for (x=0; x<events.length; x++) {
    
    var evt = events[x];
 
    var title = evt[0];
    var startTime = evt[1];
    var endTime = evt[2];
 
    calendar.createEvent(title, startTime, endTime);
  }
}

Step 3. Change the calendarId‘s value in the script (jl9l4jg8q4jdjg1qo3o202rj4c@group.calendar.google.com) to yours.

Step 4. Run the script from the Editor. For the first time you run it, again, you will be asked to authorize the script to access your data. Grant permission when requested.

Step 5. Refresh your Calendar. You’ll see new events added for the specified dates.

Calendar in Google Sheets is easy

We have explored several options for exporting Google Calendar to Google Sheets, with or without coding. If you want a simple solution, try using an Add-on or Google App Script. If you want to save time doing advanced analytics and reporting, you may want to purchase a SaaS subscription. Hopefully, one of the options explained here is the best choice for you!

Back to Blog

Comments are closed.

Access your data
in a simple format for free!

Start Free