首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用颜色出口Gcal

用颜色出口Gcal
EN

Stack Overflow用户
提问于 2022-09-19 11:21:36
回答 1查看 27关注 0票数 0

有没有办法从Goggle Calander导出颜色,并将它们发布到Goggle工作表中--我从2019年的不同网站上看到的帖子说,这种功能是不可能的,但是我用颜色来分解我的日历,我很乐意带颜色来帮助我的统计。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-19 13:07:25

您可以遵循本指南:

  1. 创建新的 Google工作表
  2. 通过绑定脚本创建一个新的Extensions > Apps Script
  3. 激活高级服务以加入日历API颜色
  4. 将此代码复制到:
代码语言:javascript
复制
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
    })]
  )
}

这将显示所有日历可用的颜色:

结果:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73772600

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档