简体   繁体   English

使用 App 脚本从 Google 表格添加或更新 Google 日历事件

[英]Add or Update Google Calendar Event from Google Sheet with App Script

I have a google sheet where each row represents an event I would like on my google calendar.我有一个谷歌表,其中每一行代表我想在我的谷歌日历上的一个事件。 Is it possible to create an App Script that updates an existing event's details if the title and time match, but creates a new event if no match is found?如果标题和时间匹配,是否可以创建一个更新现有事件详细信息的应用程序脚本,但如果找不到匹配项,则创建一个新事件? Are there any example codes of how to do this?是否有任何示例代码说明如何执行此操作? Thanks谢谢

To retrieve, try for instance (cal is your calendar and d the date)要检索,请尝试(cal 是您的日历,d 是日期)

const cal = CalendarApp.getDefaultCalendar();
const events = cal.getEventsForDay(d, { search: titre })
let event
if (events.length == 0) { event = cal.createAllDayEvent(titre, d); } else { event = events[0] }

then update event然后更新事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM