简体   繁体   English

如何自动将 Google 表格中的日程添加到日历中?

[英]how to automatically add a schedule from Google Sheets into Calendar?

I have tried to implement this code to integrate google calendar with my spreadsheet, but i am fail until now.我试图实现此代码以将谷歌日历与我的电子表格集成,但直到现在我都失败了。 Follow the code...按照代码...

function scheduleShifts() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
    var calendarId = spreadsheet.getRange("Dados!CJ3").getValue();
    var eventCal = CalendarApp.getCalendarById(calendarId);
var signups = spreadsheet.getRange("Dados!CI5:CK3500").getValues();
for (x=0; x<signups.length;x++)
{
    var shift = signups[x];
    var startTime = shift[0];
    var endTime = shift[1];
    var volunteer= shift[2];
    eventCal.createEvent(volunteer,startTime,endTime);
}
}

Error message:错误信息:

21:19:29 Erro Exception: The parameters (String,String,String) don't match the method signature for CalendarApp.Calendar.createEvent. 21:19:29 错误异常:参数(字符串、字符串、字符串)与 CalendarApp.Calendar.createEvent 的方法签名不匹配。 scheduleShifts @ Agenda.gs:12 scheduleShifts @ Agenda.gs:12

Based article:基于文章:

https://cloud.google.com/blog/products/g-suite/g-suite-pro-tip-how-to-automatically-add-a-schedule-from-google-sheets-into-calendar https://cloud.google.com/blog/products/g-suite/g-suite-pro-tip-how-to-automatically-add-a-schedule-from-google-sheets-into-calendar

Can you help me?你能帮助我吗?

Try this:尝试这个:

function scheduleShifts() {
  var spreadsheet = SpreadsheetApp.getActiveSheet();
  var calendarId = spreadsheet.getRange("Dados!CJ3").getValue();
  var eventCal = CalendarApp.getCalendarById(calendarId);
  var signups = spreadsheet.getRange("Dados!CI5:CK3500").getValues();
  for (x=0; x<signups.length;x++) {
    var shift = signups[x];
    var startTime = new Date(shift[0]);
    var endTime = new Date(shift[1]);
    var volunteer= shift[2];
    eventCal.createEvent(volunteer,startTime,endTime);
  }
}

The method signature for calendar#createEvent is calendar#createEvent的方法签名是

在此处输入图像描述

You are currently sending string parms (String,String,String).您当前正在发送字符串参数(字符串、字符串、字符串)。 As shown in the error message如错误信息所示

Exception: The parameters (String,String,String) don't match the method signature for CalendarApp.Calendar.createEvent.异常:参数(String,String,String)与 CalendarApp.Calendar.createEvent 的方法签名不匹配。 scheduleShifts排班

While the method requires that both the start date and end date are actually dates not strings.虽然该方法要求开始日期和结束日期实际上都是日期而不是字符串。

var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing',
    new Date('July 20, 1969 20:00:00 UTC'),
    new Date('July 21, 1969 21:00:00 UTC'));
Logger.log('Event ID: ' + event.getId());

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

相关问题 如何在此日历中添加时间表元素? - How to add schedule elements into this calendar? 如何从Google日历获取资源的时间表? - How can I get a resource's schedule from google calendar? 如何将多个图表从谷歌表格添加到 1 张谷歌幻灯片中 - How to add multiple charts into 1 google slides from google sheets 谷歌表格日历 - Google Sheets Calendar 从单元格自动重命名 Google Sheets 文件 - Renaming Google Sheets File Automatically From A Cell 试图让谷歌表格中的标题和日期自动与谷歌日历同步 - Trying to have title and dates in google sheets automatically sync up with a Google calendar 如何在Google表格的Datatables子行中添加图表? - how to add highcharts in Datatables child row , from google sheets? Google脚本API日历/ Google表格; 如何使用来宾(姓名,电子邮件)将日历导出到Google工作表 - Google script API calendar/google sheets; How to export calendar to google sheet with Guests (name, email) 谷歌表单编辑响应提交,自动修改工作表中的数据,以及日历事件 - Google form edit response submission, automatically modify data in sheets, as well as calendar event 如何根据谷歌表格中的范围自动更新谷歌表单中的下拉列表? - How to automatically update dropdown in a Google Form based on range in Google Sheets?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM