在对象日历中找不到函数createEvent(或createAllDayEvent)。 (Google Spreadsheet App) [英] Cannot find function createEvent (or createAllDayEvent) in object Calendar. (Google Spreadsheet App)

查看:141
本文介绍了在对象日历中找不到函数createEvent(或createAllDayEvent)。 (Google Spreadsheet App)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是我的代码导致错误。这似乎只是我尝试添加全天事件的线路。我认为这是一个日期格式问题,但我在下面注释的这一行是为了测试而创建的,它导致了相同的错误。所以我很难过。

 函数cal1(){
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; //处理
的第一行数据var numRows = 300; //要处理的行数
var dataRange = sheet.getRange(startRow,1,numRows,26); //将使用什么数据
var data = dataRange.getValues();
var cal = CalendarApp.getCalendarsByName(Production Schedule); //获取正确的日历
for(i in data){
var row = data [i];
var title = row [4]; //标题为
的列var desc = row [3]; //带描述的列
var date = row [8]; //带日期的列
var loc = row [5]; //带位置的列
cal.createAllDayEvent(title,date,{description:desc,location:loc});
//cal.createEvent(\"Test,new Date(3/10/2010 14:30:00),new Date(3/10/2010 14:30:00));



$ div $解析方案你不确定'date'变量实际上是你可以使用的日期

  cal.createAllDayEvent(title,new Date(日期),{描述:desc,位置:loc}); 

表示,使用记录器检查相当容易

  Logger.log(日期)

应该以的形式返回日期值Tue Sep 18 03:00:00 PDT 2012


Okay here is my code that is causing the error. It seems to be just the line where I attempt to add the all day event. I thought it was a date formatting issue but the line I commented out below it was created to test that and it resulted in the same error. So I am stumped. What needs to change to correct the error, or what does the error actually mean.

    function cal1() {
      var sheet = SpreadsheetApp.getActiveSheet();
      var startRow = 2;  // First row of data to process
      var numRows = 300;   // Number of rows to process
      var dataRange = sheet.getRange(startRow, 1, numRows, 26); //What data will be used
      var data = dataRange.getValues();
      var cal = CalendarApp.getCalendarsByName("Production Schedule"); //Gets the correct calendar
    for (i in data) {
      var row = data[i];
      var title = row[4];  // Column with Title
      var desc = row[3];       // Column with Description
      var date = row[8];   //Column with Date
      var loc = row[5];    //Column with Location
      cal.createAllDayEvent(title, date, {description:desc,location:loc});
      //cal.createEvent("Test", new Date("3/10/2010 14:30:00"), new Date("3/10/2010 14:30:00"));  
  }
 }

解决方案

if you are not sure about the 'date' variable being actually a date you could use

  cal.createAllDayEvent(title, new Date(date), {description:desc,location:loc});

that said, it is quite easy to check with the logger

Logger.log(date)

should return a date value in the form Tue Sep 18 03:00:00 PDT 2012

这篇关于在对象日历中找不到函数createEvent(或createAllDayEvent)。 (Google Spreadsheet App)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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