Skip to content
// Calendar · Sheets

Sync Google Calendar events into a spreadsheet for reporting.

Pull every event from your primary calendar for the next 30 days into a Sheet — start, end, title, location, attendees. Idempotent: re-running gives a fresh snapshot, not duplicates.

“I want my next month of meetings as rows in a sheet so I can pivot, sort, and report on them.”

The script

copy · paste · trigger
syncCalendarToSheet.gs
Apps Script
// Pull events from the user's primary calendar for the next 30 days
// into the active sheet. Clears prior data rows so re-running is a
// fresh snapshot, not an append.
function syncCalendarToSheet() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const cal = CalendarApp.getDefaultCalendar();

  const now = new Date();
  const end = new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000);
  const events = cal.getEvents(now, end);

  // Clear previous rows, leaving the header.
  if (sheet.getLastRow() > 1) {
    sheet.getRange(2, 1, sheet.getLastRow() - 1, 5).clearContent();
  }

  events.forEach(e => {
    sheet.appendRow([
      e.getStartTime(),
      e.getEndTime(),
      e.getTitle(),
      e.getLocation() || '',
      e.getGuestList().map(g => g.getEmail()).join(', '),
    ]);
  });
}

Need a variant? Gnaw writes a custom version from one sentence — fields, triggers, edge cases handled.

Walkthrough

How it works

CalendarApp.getDefaultCalendar() picks the user's primary calendar — the one tied to the Google account the script runs as. For shared/team calendars, swap to CalendarApp.getCalendarById('<calendar id>').

getEvents(start, end) includes events that overlap the reporting window. A handover from 08:30 to 09:30 appears in a report starting at 09:00. The end of the window is exclusive.

The clearContent() step is what makes the script idempotent. Without it, every run would append duplicates. Header row stays — only data rows get wiped.

How to schedule it

Add a daily time-based trigger via the Triggers panel. Daily is the right cadence — calendar churn is faster than weekly but slower than hourly, and the snapshot is cheap.

If you want change-detection (alert me when a meeting moves), keep this script for the snapshot and add a second script that diffs the latest snapshot against the previous one (store previous in PropertiesService).

Common pitfalls

For a large export, the occurrence report below uses the Calendar API’s nextPageToken to read each page.

Time zones: The date and time a Sheet displays depend on its spreadsheet time zone. Set explicit offsets when choosing the reporting window, especially when the calendar and workbook have different time zones.

Keep one row per occurrence. CalendarEvent.getId() returns the iCalendar UID, which the occurrences of one series share. Grouping by the series ID collapses those rows. The Calendar API exposes a different event id for each occurrence.

Keep the moved meeting and its two neighbors

Three studio checks start at 10:00 UTC on January 5, 6 and 7. Move the January 6 check to noon. A useful report still shows three separate occurrences. The moved row keeps its original 10:00 start alongside its current 12:00 start. A fourth row, an 08:30–09:30 handover, overlaps the 09:00 reporting boundary.

For the same calendar, compare the Calendar API occurrence ID across reports. The series ID repeats. The original start identifies a slot within that series even after its current start changes. An ordinary one-off event has no original recurrence slot.

In a spreadsheet’s Apps Script editor, add Calendar API under Services. Paste the report below, enter the calendar ID from its settings, set the two date-time boundaries with their offsets and run exportOccurrenceReport. Each run creates a new report tab. The script reads Calendar events and writes the six report columns to that spreadsheet.

Download the Apps Script occurrence report

Google Calendar recurring events and instances · CalendarApp reporting windows

Want a custom version?

Describe your sheet and the rule you want. Gnaw writes the Apps Script — fields, triggers, edge cases — in one shot.

FAQ

4 questions
Can I sync from a shared team calendar?
Yes. Replace getDefaultCalendar() with getCalendarById('<id>'). Find the ID in Calendar settings → Integrate calendar → Calendar ID.
How do I include declined events?
By default getEvents returns everything you're invited to, including declined. Filter with `events.filter(e => e.getMyStatus() !== CalendarApp.GuestStatus.NO)`.
Why is the attendee column blank?
getGuestList() returns guests other than the script owner. Solo events have no guests, so the column is empty by design.
Can I sync to a sheet in a different workbook?
Yes. Replace getActiveSheet() with SpreadsheetApp.openById('<id>').getSheetByName('<name>'). The trigger needs to be installable (not simple) for cross-document writes.