jordan rhea header

Adding Rows to a Sheet from a WebApp

November 29th, 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(

  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 wearing a hoodie
Written by jordan rhea Building tools and connecting systems