These blog posts are part of research I’m doing for a potential new book, hopefully allowing me to further my love for spreadsheets. Theses posts are hoping to provide a practical cookbook of examples to the reader and allow me to learn what people are interested in and how to approach different subjects working with Google Sheets.
TLDR: In this post we will discuss how to use Google Sheets to prototype apps and services you might want to put together for users. The complete sheet can be found at the following link:
https://docs.google.com/spreadsheets/d/1OdyefCS9GwbvX21pFfv5n584qU0aX5vvNEyfPhpbsbE/copy
If you have an idea but want to get it live without both spending money and too much time setting this up. There are really great ways to utilise Google Sheets to get a service live and running pretty quickly and allow you to see if you should be spending more time and effort on what seems like a great idea.
In this post we are going to work through a really simple project but then use Google Sheets to put it online to allow multiple users to access and use it. The project is pretty simple. I do a weekly run with a group on Friday mornings, which usually involves multiple repeats of a certain course where we run. We usually rely on one specific member of the group to go through their training history and post the run, that usually alternates over about 8 different sessions.
So the goal of this service will be to add these training runs into a sheet and have the training sessions rotate over the weeks. Then with this service online, it will then allow anyone who has access to the service will be able to see the training run that is happening this week.
What You Need To Know To Get This Done?
So far we have steered clear of using AppScript so far, but in this post we are going to use AppScript to do our major block of work for us. Don’t worry though, we are doing to take things pretty easily and explain all the code we are working through. The set up and creation of our sheet is actually going to be pretty easy and you won’t even need any functions or formulas to create it. All you will need is access to Google Sheets.
Our sheet is going to be pretty simple. The image below gives you everything you need to know to set this up.
MT EDEN HILL REPEATS
Come see the new year in from the top of Mt Eden. 3 or 4 times.
Depart grandstand 6:30am to head to Mt Eden via Mountain & Clive Roads.
4 x steady up and over in clockwise direction, starting at entrance on Mt Eden Rd and easy back down as your recovery.
Slower/injured/special guest runners either do 2 or 3 full ones or some just from and around the roundabout. Or a mix...
Run intervals suggestion for tomorrow:
15/20 minute warm up.
1k steady,
1k as 500 steady then 500 fast.
1k as 500 fast then 500 steady.
And repeat once more.
Slower runners/time poor could do them as 800’s or just do 4 of the 1k’s. 10/15 min warm down
15-20min w/up
Steady/Fast pairs :
2x(400m/200m easy)
2x(600m /200m Easy)
2x(800m /200m Easy)
2x(1km/200m easy)
10-15 min cool down
The rest of our training weeks are listed in our example, but we will only show you these cells for now, but feel free to add in the rest of the training sessions we have posted in our sheet template.
It’s time to add in out App Script that will now move our data around making sure we have a new training session each Friday morning.
function rotateColumnB() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getRange("B4:B9");
var values = range.getValues();
var first = values[0][0];
for (var i = 0; i < values.length - 1; i++) {
values[i][0] = values[i + 1][0];
}
values[values.length - 1][0] = first;
range.setValues(values);
}
NOTE: If you are doing this for the first time, you might need to verify permissions to allow this function to run. Simply follow the pop up, and approve where needed to
Instead of running the function manually whenever we want the cells to be rotated through, we can instead set the function to be run after a certain event of time of day. On the left hand menu of the App Script code editor, there is a Triggers option. Click on that now.
Now we want to be able to allow other users to access our new service. We could simply share the sheet, but this might not be convenient for everyone, and simply sharing a web page might be a little easier.
You should now be presented with a large URL, you can now share with other people. The image below shows the page displayed in my cell phone.
Once you are no longer using this service, make sure to always stop publishing, by going to the same “Publish to web” option and clicking on “Stop Publishing”. If you try using the original link again, you should get an error stating “We’re sorry. This document is not published”
We’ve done a lot of cool work here to get our small service up and running and live on the internet. We created a nice little sheet that displayed our weekly Friday run session for the coming month or two. We set up some basic App Script code that rotates the cells for us, and set the function to run automatically every week, so we don’t need to touch anything for it to work.
In the end, we then used Google Sheets share option to Publish our sheet to the web. This allowed us to now share this sheet with anyone who wants to see an use it. Although, the URL is long and not something you can remember, like I said this is just a prototype, and something we can fix up long term.
The post is written by Vincent Sesto, a Aussie Software Engineer, living and working in Auckland, New Zealand. If you are interested in my authors page on Amazon, feel free to checked it out at the following link:
https://us.amazon.com/stores/author/B073R3VW2G