更改日历事件的颜色 [英] Changing calendar event color

查看:69
本文介绍了更改日历事件的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够以编程方式更改日历事件的颜色.我正在阅读本文档,但是不明白键"在这里指的是什么: https://developers.google.com/google-apps/calendar/v3/reference/colors .是事件ID吗?

I'd like to be able to programmatically change the color of calendar events. I was going through this documentation, but don't understand what the "key" is referring to here: https://developers.google.com/google-apps/calendar/v3/reference/colors. Is it the event ID?

我还想知道是否可以通过电子表格更改日历事件的颜色.我有一个脚本,可以将电子表格中的条目添加到日历中,但是我也希望能够定义颜色.如果可以的话,请向我指出有用的阅读材料或示例.

I'd also like to know if it's possible to change a calendar event color via a spreadsheet. I have a script to add entries from a spreadsheet to a calendar, but I want to be able to define the colors as well. Please point me to helpful reading material or examples if possible.

编辑2015年12月20日-添加的工作脚本以添加事件:

Edit 12/20/2015- added working script to add events:

function createEvent() {
var calendarId = 'MY_ID';
var event = {
summary: 'test',
description: 'test desc',
"end": {
"date": "2015-12-21"
},
"start": {
"date": "2015-12-21"
},
colorId: 10
};
event = Calendar.Events.insert(event, calendarId);
Logger.log('Event ID: ' + event.getId());
}

推荐答案

哦,您是否对Google缺少有关此文档的文件感到困惑?不用担心,我也是.

Oh, are you confused by Google's lack of documentation on this? Don't worry, so was I. Here's a chart of the numbers (keys) and the associated colors. Looks something like this in the end:

var event = {
    summary: "Summarizing",
    description: "Descriptive",
    start: {
      date: Utilities.formatDate(start, "GMT-5", "yyyy-MM-dd")
    },
    end: {
      date: Utilities.formatDate(end, "GMT-5", "yyyy-MM-dd")
    },
    colorId: 10
  };
  event = Calendar.Events.insert(event, calendarId); 
 }

希望有帮助!第二部分:应该可以,只需确保您使用的是Google Calendar Advanced服务.没有更多关于您要做什么的详细信息,很难提供更多信息:/

Hope that helps! For the second part: It should be possible, just make sure you're using the Google Calendar Advanced service. Without more detail about what you're trying to do, it's hard to provide more info :/

这篇关于更改日历事件的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆