You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过CalendarEvent对象ID获取Google日历事件的HTTPS链接?

获取Google日历事件的HTTPS链接及快捷访问方案

直接构造事件HTTPS链接

Google日历事件的访问链接有固定格式,用你获取到的事件ID直接拼接即可:

  • 查看详情链接:https://calendar.google.com/calendar/u/0/r/eventdetails/${事件ID}
  • 编辑事件链接:https://calendar.google.com/calendar/u/0/r/eventedit/${事件ID}

把Sheet中存储的事件ID替换掉链接里的${事件ID},再将单元格设置为超链接(右键单元格→插入链接),就能避免触发邮件发送,点击直接打开日历事件页面。

用Apps Script打开新标签页

在Sheets的脚本编辑器中添加以下代码,可通过按钮或自定义菜单触发打开事件:

function openCalendarEvent(eventId) {
  const eventUrl = `https://calendar.google.com/calendar/u/0/r/eventdetails/${eventId}`;
  // 通过弹窗脚本打开新标签页
  SpreadsheetApp.getUi().showModalDialog(
    HtmlService.createHtmlOutput(`<script>window.open('${eventUrl}');google.script.host.close();</script>`),
    '打开日历事件'
  );
}

使用时,给Sheet添加按钮并绑定该函数,或通过自定义菜单传入目标事件ID即可。

在Sheet内预览日历事件

如果想在Sheet内直接查看事件,可通过脚本生成嵌入预览弹窗:

function showEventPreview(eventId) {
  const embedUrl = `https://calendar.google.com/calendar/embed?src=${CalendarApp.getDefaultCalendar().getId()}&ctz=${Session.getScriptTimeZone()}&mode=AGENDA&events=${eventId}`;
  const html = HtmlService.createHtmlOutput(`<iframe src="${embedUrl}" width="600" height="400" frameborder="0"></iframe>`)
    .setWidth(620)
    .setHeight(420);
  SpreadsheetApp.getUi().showModalDialog(html, '日历事件预览');
}

内容的提问来源于stack exchange,提问作者Claude Martin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 17:15:36