<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>OUseful.Info, the blog... &#187; Updating Google Calendars from a Google Spreadsheet</title>
	<atom:link href="http://blog.ouseful.info/2010/03/04/maintaining-google-calendars-from-a-google-spreadsheet/feed/?withoutcomments=1" rel="self" type="application/rss+xml" />
	<link>http://blog.ouseful.info</link>
	<description>Trying to find useful things to do with emerging technologies in open education</description>
	<lastBuildDate>Sun, 19 May 2013 20:47:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.ouseful.info' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>OUseful.Info, the blog... &#187; Updating Google Calendars from a Google Spreadsheet</title>
		<link>http://blog.ouseful.info</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.ouseful.info/osd.xml" title="OUseful.Info, the blog..." />
	<atom:link rel='hub' href='http://blog.ouseful.info/?pushpress=hub'/>
		<item>
		<title>Updating Google Calendars from a Google Spreadsheet</title>
		<link>http://blog.ouseful.info/2010/03/04/maintaining-google-calendars-from-a-google-spreadsheet/</link>
		<comments>http://blog.ouseful.info/2010/03/04/maintaining-google-calendars-from-a-google-spreadsheet/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 20:20:41 +0000</pubDate>
		<dc:creator>Tony Hirst</dc:creator>
				<category><![CDATA[Google Apps]]></category>
		<category><![CDATA[Tinkering]]></category>
		<category><![CDATA[apps script]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[spreadsheet]]></category>

		<guid isPermaLink="false">http://ouseful.wordpress.com/?p=2983</guid>
		<description><![CDATA[I got a request today along the lines of: We’re in the process of creating a master calendar of events spreadsheet relevant to [various things]. These [various things] will all then have their own Google calendar so they can be looked at individually, embedded etc and everyone could of course have access to all and [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.ouseful.info&#038;blog=325417&#038;post=2983&#038;subd=ouseful&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I got a request today along the lines of:</p>
<blockquote><p>We’re in the process of creating a master calendar of events spreadsheet relevant to [various things]. These [various things] will all then have their own Google calendar so they can be looked at individually, embedded etc and everyone could of course have access to all and view them all via their personal Google calendar, turn different calendars on or off, sync with Outlook etc. etc.</p>
<p>X said “wouldn’t it be great if we made the master spreadsheet with Google docs and it could somehow automate and complete the calendars”.</p></blockquote>
<p>Sigh&#8230;;-) So &#8211; is it possible?</p>
<p>I&#8217;ve only had a quick play so far with Google Apps script, but yes, it seems to be possible&#8230;</p>
<p>Take one spreadsheet, liberally sprinkled with event name, description, start and end times, an optional location, and maybe a even a tag or too (not shown):</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4407171330/" title="Photo Sharing"><img src="http://farm5.static.flickr.com/4057/4407171330_01c7b36281.jpg" width="500" height="89"></a></p>
<p>The time related columns I specified as a date type using the &#8220;Data Validation&#8230;&#8221; form from the Tools menu:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4406423579/" title="Photo Sharing"><img src="http://farm5.static.flickr.com/4020/4406423579_6277a1150d.jpg" width="467" height="274"></a></p>
<p>Now take one Google apps script:</p>
<pre class="brush: jscript; title: ; notranslate">function caltest1() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 2;  // First row of data to process
  var numRows = 2;   // Number of rows to process
  var dataRange = sheet.getRange(startRow, 1, numRows, 5);
  var data = dataRange.getValues();
  var cal = CalendarApp.getDefaultCalendar();
  for (i in data) {
    var row = data[i];
    var title = row[0];  // First column
    var desc = row[1];       // Second column
    var tstart = row[2];
    var tstop = row[3];
    var loc = row[4];
    //cal.createEvent(title, new Date(&quot;March 3, 2010 08:00:00&quot;), new Date(&quot;March 3, 2010 09:00:00&quot;), {description:desc,location:loc});
    cal.createEvent(title, tstart, tstop, {description:desc,location:loc});
 }
}</pre>
<p>(This was largely a copy and paste from <a href="http://www.google.com/google-d-s/scripts/sending_emails.html">Sending emails from a Spreadsheet Tutorial</a>, which I&#8217;d half skimmed a week or two ago and seemed to remember contained a howto for bulk mailing from a spreadsheet, and the Apps script <a href="http://www.google.com/google-d-s/scripts/class_calendar.html">Calendar class documentation</a>.)</p>
<p>And here&#8217;s the result of running the function:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4407183584/" title="Photo Sharing"><img src="http://farm5.static.flickr.com/4049/4407183584_9b4e2e64cd.jpg" width="500" height="413"></a></p>
<p>The email tutorial adds a bit of gloss that allows a further column to contain state information about whether an email has already been set; we could do something similar to specify whether or not an event has been automatically added to the calendar, and if not, add it when the function is run.</p>
<p>Because it can be a pain having to go into the script editor to run the function, it&#8217;s easier to just <a href="http://www.google.com/google-d-s/scripts/defining_menus.html">create a menu option</a> for it:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4407234252/" title="Photo Sharing"><img src="http://farm3.static.flickr.com/2793/4407234252_0711ed73da.jpg" width="500" height="109"></a></p>
<p>Here&#8217;s how:</p>
<pre class="brush: jscript; title: ; notranslate">function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var menuEntries = [ {name: &quot;Shove stuff in calendar&quot;, functionName: &quot;caltest2&quot;} ];
  ss.addMenu(&quot;OUseful&quot;, menuEntries);
}</pre>
<p>I had a little play to see if I could trivially get an RSS feed into the spreadsheet using an <em>=importFeed()</em> formula, and use the details from that to populate the calendar, but for some reason the feed importer function didn&#8217;t appear to be working?:-( When I tried using CSV data from a Yahoo RSS2CSV proxy pipe via a <em>=importData()</em> formula, the test function I&#8217;d written didn&#8217;t appear to recognise the date format&#8230;</p>
<p>PS Arghh&#8230; the test formula assumes a Date type is being passed to it&#8230; Doh!</p>
<p>Hack round importFeed still not working by grabbing a CSV version of the feed into the spreadsheet:<br />
<em>=importdata(&#8220;<a href="http://pipes.yahoo.com/ouseful/proxy?_render=csv&#038;url=http%3A%2F%2Fopen2.net%2Ffeeds%2Frss_schedule.xml&#038;#8221" rel="nofollow">http://pipes.yahoo.com/ouseful/proxy?_render=csv&#038;url=http%3A%2F%2Fopen2.net%2Ffeeds%2Frss_schedule.xml&#038;#8221</a>;)</em></p>
<p>Tweak the calendar event creation formula:</p>
<pre class="brush: jscript; title: ; notranslate">cal.createEvent(title, new Date(tstart), new Date(tstop), {description:desc});</pre>
<p>Run the function:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/4407221820/" title="Photo Sharing"><img src="http://farm3.static.flickr.com/2789/4407221820_823254fd74.jpg" width="500" height="264"></a></p>
<p>Heh heh :-)</p>
<p>PS it&#8217;s also possible to move content <em>from</em> a Google Calendar to a Google spreadsheet, as <a href="http://blog.ouseful.info/2010/03/05/grabbing-google-calendar-event-details-into-a-spreadsheet/">Grabbing Google Calendar Event Details into a Spreadsheet</a> shows&#8230;</p>
<p>PPS it strikes me that the spreadsheets2calendar route provides one way of generating an iCal feed from a list of event times held in a spreadsheet, by popping the events into a Calendar and then making the most of its output formats? A bit like using Yahoo pipes as a quick&#8217;n'easy KML generator?</p>
<p>[UPDATE: related, via @mhawksey - <a href="http://www.rsc-ne-scotland.org.uk/mashe/2010/03/using-google-apps-script-for-a-event-booking-system/">Using Google Apps Script for a event booking system (Spreadsheet to Calendar &amp; Site | Form to Spreadsheet, Email and possible Contacts)</a>]</p>
<p>Re: not creating duplicate entries, check out <a href="http://productforums.google.com/forum/#!msg/calendar/dXiatdaKaL4/_sgAHPQyJpwJ">this thread</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ouseful.wordpress.com/2983/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ouseful.wordpress.com/2983/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.ouseful.info&#038;blog=325417&#038;post=2983&#038;subd=ouseful&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.ouseful.info/2010/03/04/maintaining-google-calendars-from-a-google-spreadsheet/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/abbd9f90565ce9ae4d065d93a81d8c03?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Tony Hirst</media:title>
		</media:content>

		<media:content url="http://farm5.static.flickr.com/4057/4407171330_01c7b36281.jpg" medium="image" />

		<media:content url="http://farm5.static.flickr.com/4020/4406423579_6277a1150d.jpg" medium="image" />

		<media:content url="http://farm5.static.flickr.com/4049/4407183584_9b4e2e64cd.jpg" medium="image" />

		<media:content url="http://farm3.static.flickr.com/2793/4407234252_0711ed73da.jpg" medium="image" />

		<media:content url="http://farm3.static.flickr.com/2789/4407221820_823254fd74.jpg" medium="image" />
	</item>
	</channel>
</rss>
