my code stock.com

John Galve

Google Apps: From Google Calendar to Google Spreadsheet
by John Galve

Convert Google Calendar schedules into rows in Spreadsheet.

Snippet options

Download: Download snippet as google-apps-from-google-calendar-to-google-spreadsheet.js.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

function caltest3(){
  //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 calid = "calendar id"; // Calendar ID
  var cal = CalendarApp.getCalendarById(calid); // Get the id of calendar that will be use
  var sheet = SpreadsheetApp.openByUrl("spreadsheet url");
  var mainSheet = sheet.getSheetByName("sheet name");//sheet name
  var numRows = mainSheet.getMaxRows();
  
  for(var row=2;row<numRows;row++)
  {
  
  var range = mainSheet.getRange(row, 1);
  var status = range.getValue();         
  range = mainSheet.getRange(row, 6);
  var id = range.getValue();
  var events = cal.getEventSeriesById(id);
  if(status!="TBA")
    {
    var title=events.getTitle();
    var desc=events.getDescription();
    var loc=events.getLocation();
    
    mainSheet.getRange(row, 2).setValue(title);
    mainSheet.getRange(row, 8).setValue(desc);
    mainSheet.getRange(row, 11).setValue(loc);
    }
    
  }
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.