将日历添加到StackPanel

时间:2013-10-09 13:30:44

标签: google-apps-script google-calendar-api

我可以将Google日历添加到StackPanel吗?

function calendar(app){
  return HtmlService.createHtmlOutputFromFile('calendar');
}

**** HTML FILE ****
<html>
  <iframe src="http://www.google.com/calendar/embed?src=davie.k12.nc.us_d2mv2eb8aspuant1vb5j6r3sis%40group.calendar.google.com&ctz=America/New_York" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>
</html>

1 个答案:

答案 0 :(得分:1)

您可以将所需的事件日期,标题和详细信息提取到自定义视图中,但如果您只是将日历网址添加到该特定面板,则不会显示。您可以使用HtmlService对其进行iframe。

function doGet() {
  var cal = CalendarApp.getCalendarsByName(YOUR_CAL_NAME)[0];
  var app = UiApp.createApplication();
  var panel = app.createStackPanel();
  var start = new Date();
  var end = new Date(new Date().getTime() + 7 * 86400000);
  var events = cal.getEvents(start, end);
  var tz = cal.getTimeZone();
  var i, len, html = '';

  for (i = 0, len = events.length; i < len; i++) {
    html += events[i].getTitle() + ' ' + Utilities.formatDate(events[i].getStartTime(), tz, 'MM-dd-yyyy') + '<br>';
  }

  panel.add(app.createHTML(html));
  app.add(panel);

  return app;
}