Google日历与Google电子表格同步 [英] Google calendar sync with google spreadsheet

查看:114
本文介绍了Google日历与Google电子表格同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个非常棒的脚本,可以同步Google CAL和Google电子表格.双向同步.而且有效!-> https://github.com/Davepar/gcalendarsync

I've found this pretty awesome script that syncs btw google cal and google spreadsheet. Two-way sync. And it works! -> https://github.com/Davepar/gcalendarsync

现在,我将无法在名为Data的工作表中输入日历的地址.在单元格B1中.脚本应该从那里拉地址,这样我就不需要在脚本中更改它了.

Now I wan't to be able to put in the address of the calendar in a sheet named Data. In cell B1. The script should pull the address from there so that I wouldn't need to change it in the script.

有人可以弄清楚该怎么做吗?
更改将涉及通过Data!B1
来定义calendarId而且该脚本只能在表格上运行

Can someone figure out how to do that?
The changes would involve to define calendarId by Data!B1
And the script should only run on the Sheet

您可以在此处查看示例文档: https://docs.google.com/spreadsheets/d/1TCIIBRmshx2kmhhwrhCpg5sxO7N82tOJ7hHxWv_u-Yw/edit?usp=sharing

You can see sample doc here: https://docs.google.com/spreadsheets/d/1TCIIBRmshx2kmhhwrhCpg5sxO7N82tOJ7hHxWv_u-Yw/edit?usp=sharing

我在工作表脚本上复制了脚本

I made a copy of the script on the Sheet Script

推荐答案

日历ID在第8行上声明

The calendar id is declared on line 8

var calendarId = 'bora-bora.dk_is0cr9ibe4thrs4mkqghvudrrk@group.calendar.google.com';

它由两个函数调用:
1 =第223行的 syncFromCalendar .从日历同步到电子表格.

It is called by two functions:
1 = syncFromCalendar on line 223. Synchronize from calendar to spreadsheet.

var calendar = CalendarApp.getCalendarById(calendarId);

307行上的

2 = syncToCalendar .从电子表格同步到日历.

2 = syncToCalendar on line 307. Synchronize from spreadsheet to calendar.

var calendar = CalendarApp.getCalendarById(calendarId);

目标是通过编程方式调用日历ID,以从数据表的单元格B1中获取值.
为此,i)应该删除变量,ii)添加/插入新代码以获取日历ID的新值,并且iii)对要求日历ID值的函数进行调整.

The goal is to call the calendar ID programmatically to source the value from Cell B1 of the Data Sheet.
To do this, i) the variable should be removed, ii) add/insert new code to source the new value for the calendar ID, and iii) make adjustments to the functions that call for the value of the calendar ID.

1-注释掉第8行
2-在第9行插入以下代码

1 - comment out Line 8
2 - Insert the following code at Line 9

// Get the calendar code from Sheet "Data", cell B1
function getcalendarId() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getSheetByName("Data");
  var calrange = sheet.getRange("B1");
  var calid =calrange.getValue();
  return calid;
}

3-查找功能= syncFromCalendar
3.1-将此行注释掉

3 - Locate function = syncFromCalendar
3.1 - Comment out this line

var calendar = CalendarApp.getCalendarById(calendarId);

3.2在注释行上方插入/添加这三行

3.2 Insert/add these three lines above the commented line

// Get the calendar ID
var calidFrom = getcalendarId();
var calendar = CalendarApp.getCalendarById(calidFrom);

4-查找功能= syncToCalendar
4.1注释掉这一行

4 - Locate function = syncToCalendar
4.1 Comment out this line

var calendar = CalendarApp.getCalendarById(calendarId);

4.2在注释行上方插入/添加这三行

4.2 Insert/add these three lines above the commented line

// Get the calendar ID
var calidTo = getcalendarId();
var calendar = CalendarApp.getCalendarById(calidTo);

这篇关于Google日历与Google电子表格同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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