This is the gatsby-styled-blog-starter demo site. To download the code and get some instructions visit the Github repository . To be informed about updates follow @greglobinski

Adding Rows to a Sheet from a WebApp

A demonstration of the doPost(e) trigger using a web app

November 28, 2017

A great community suggestion from John Galla in the comments of a previous video!

The file is simply:

function doGet() {
  return HtmlService.createHtmlOutputFromFile('index').setTitle('Adding Rows');

function sendText(data) {
  var sheet =SpreadsheetApp.openById('1bpPJq8U4QIAN_ojHdipP9h9Qvu2aaJpy7CSbIFA_DRM').getActiveSheet();

  sheet.appendRow([data.studentName, data.studentSentence]);

  return 'Success!';

Then, on the front-end of your project, you need to do some work! When you send and recieve data from a webpage without reloading or redirecting, this is called ‘asynchronous’ and can be achieved with some simple Javascript.

<form onsubmit="sendText(event)">
  <input type="text" name="student-name" />

  <input type="text" name="student-sentence" />

  <input type="submit" value="submit" />

function sendText(e) {

  var data = {
    .withSuccessHandler(function(response) {

Often, in my html files involved in an Apps Script project, I just put the JavaScript inline with the rest of the code. This cuts down on clutter. If your files get too big though, you can easily break them into multiple template files.

If you have an idea for a project, or need some help with Google Apps Script… let me know in my new Reddit Community: Teachers Can Code!

Please help me out by sharing any of my projects that you like with teachers that you know!


jordan rhea I started as a teacher and taught myself to code with Python and JavaScript. Now I am passionate about sharing code and strategies to make teachers (and other G Suite users) as effective as possible with technology.

© jordan rhea 2018