0
我正在使用Google腳本從資源日曆中提取數據。該腳本按預期提取單個日曆,但我想將多個資源日曆提取到1個工作表中。有人能指引我朝着正確的方向嗎?我已經着眼於創建一個包含多個日曆到'mycal'的數組,但是我無法運行它。由於將多個Google日曆提取到單個Google工作表
function export_gcal_to_gsheet(){
var mycal = "[email protected]";
var cal = CalendarApp.getCalendarById(mycal);
var today = new Date();
var events = CalendarApp.getCalendarById(mycal).getEventsForDay(today);
var sheet = SpreadsheetApp.getActiveSheet();
sheet.clearContents();
var header = [["Calendar Address", "Event Title", "Event Description", "Event Location", "Event Start", "Event End", "Calculated Duration", "Visibility", "Date Created", "Last Updated", "MyStatus", "Created By", "All Day Event", "Recurring Event"]]
var range = sheet.getRange(1,1,1,14);
range.setValues(header);
for (var i=0;i<events.length;i++) {
var row=i+2;
var myformula_placeholder = '';
var details=[[mycal,events[i].getTitle(), events[i].getDescription(), events[i].getLocation(), events[i].getStartTime(), events[i].getEndTime(), myformula_placeholder, ('' + events[i].getVisibility()), events[i].getDateCreated(), events[i].getLastUpdated(), events[i].getMyStatus(), events[i].getCreators(), events[i].isAllDayEvent(), events[i].isRecurringEvent()]];
var range=sheet.getRange(row,1,1,14);
range.setValues(details);
var cell=sheet.getRange(row,7);
cell.setFormula('=(HOUR(F' +row+ ')+(MINUTE(F' +row+ ')/60))-(HOUR(E' +row+ ')+(MINUTE(E' +row+ ')/60))');
cell.setNumberFormat('.00');
}
}