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) returns every event whose start time falls in the range. The 30-day window here is the typical reporting horizon; lengthen by changing the multiplier.
The clearContent() step is what makes the script idempotent. Without it, every run would append duplicates. Header row stays — only data rows get wiped.