在 Windows 7 机器上运行 firefox 23.0.1
我正在尝试将一长串日期(1,000-2,000)从我的日历导入电子表格。它工作得很好,直到我开始添加我所有的学生课程会议。现在它似乎工作了,但我收到了超时消息,这需要很长时间。
有一张单独的表格,只记录 A1:学生姓名、B1:位置和 C:1 开始时间
function calpull(){
//http://www.google.com/google-d-s/scripts/class_calendar.html#getEvents
// The code below will retrieve events between 2 dates for the user's default calendar and
// display the events the current spreadsheet
var cal = CalendarApp.getDefaultCalendar();
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheets()[1];
var events = cal.getEvents(new Date("August 15,2013"), new Date("January 15, 2014"));
for (var i=0;i<events.length;i++) {
//http://www.google.com/google-d-s/scripts/class_calendarevent.html
var details=[[events[i].getTitle(), events[i].getLocation(), events[i].getStartTime(),]];
// the +3 makes the data start on the third row, protecting the first two rows
var row=i+3;
//for some unknown reason, I have to set the active sheet here
var range=SpreadsheetApp.getActiveSpreadsheet().getSheets()[1].getRange(row,1,1,3);
range.setValues(details);
}
}
我的问题是,我认为它会单独读取每个事件,并将其放在一行中。我试图弄清楚如何将我想要的所有数据保存到一个数组中,然后将数组一次保存到电子表格中。
我的最后一次脚本尝试看起来像这样,但不起作用:
function calpull(){
//http://www.google.com/google-d-s/scripts/class_calendar.html#getEvents
// The code below will retrieve events between 2 dates for the user's default calendar and
// display the events the current spreadsheet
var cal = CalendarApp.getDefaultCalendar();
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheets()[1];
var events = cal.getEvents(new Date("August 15,2013"), new Date("August 15, 2014"));
for (var i=0;i<events.length;i++) {
//http://www.google.com/google-d-s/scripts/class_calendarevent.html
var details=[[events[i].getTitle(), events[i].getLocation(), events[i].getStartTime(),]];
// the +3 makes the data start on the third row, protecting the first two rows
var row=i+3;
//for some unknown reason, I have to set the active sheet here
var range=ss.getRange(row,1,1,3);
range.setValues(details);
}
}
我的问题是,我认为它会单独读取每个事件,并将其放在一行中。我试图弄清楚如何将我想要的所有数据保存到一个数组中,然后将数组一次保存到电子表格中。
非常菜鸟问题,我似乎总是缺少一些基本信息。每个人都认为我会知道。