Exporting Gcal with Colours

Viewed 19

Is there any way to export colours from Goggle Calander and post them into Goggle Sheets - I've seen posts from 2019 from various sites saying that this functionality was impossible, but I use colours to break up my calendar and I would love to bring colours over to help with my stats.

1 Answers

You can follow this guide:

  1. Create a new Google Sheet
  2. Create a new Bound Script via Extensions > Apps Script
  3. Activate Advanced Service for accesing Calendar API Colors
  4. Copy this code in:
const sS = SpreadsheetApp.getActiveSheet()
function bringCalendarToSheet() {
  // Getting the colors for the Calendar and Events
  const colors = Calendar.Colors.get()
  const colorsCalendar = colors.calendar
  const colorsEvents = colors.event
  // Parsing and setting the data for the Calendar Colors
  const A1 = sS.getRange('A1').setValue('Calendar Colors')
  const colorsCalendarLength = Object.keys(colorsCalendar).length
  const rCC = sS.getRange(2, 1, 1, colorsCalendarLength).setBackgrounds([Object.keys(colorsCalendar).map(k => {
    return colorsCalendar[k].background
  })])
  // Parsing and setting the data for the Event Colors
  const A3 = sS.getRange('A3').setValue('Event Colors')
  const colorsEventsLength = Object.keys(colorsEvents).length
  const rEC = sS.getRange(4, 1, 1, colorsEventsLength).setBackgrounds(
    [Object.keys(colorsEvents).map(k => {
      return colorsEvents[k].background
    })]
  )
}

This will show all Calendar available colors:

Result:

Result

Related