Tuesday, May 26, 2020

Insert operation on Spread Sheet using Google Apps script

In this article, i am going to work on insert the data from html to google spread sheet using java script and apps script. apps script is used to manage the G Suite to automate the documentation and etc.

Insert operation on Spread Sheet using Google Apps script

In this project, we can find the 2 main steps. each step has its own coding. step one has the pure Apps Script and the second step has html with java script.

Step 1. Here,  I am going to create apps script for insert operation. Before creating apps script we have to create the spread sheet and take spread sheet id.

          1. Login Gmail account
          2. Go to Google Drive
          3. Create new Spread Sheet and save as "Give any name here"
          4. Click on Tools
          5. Click on Script Editor
Note: At point number 3, Please take the spreadsheet id as shown below image and keep it in note pad for future reference. take the id after back slash as shown below image.

get Google  Spread Sheet id

In spread sheet please give some column names as shown below image

spread sheet google apps script

click on Tools --> go to Script editor and write the required code for insert operation.

  •  e.parameter.action  is used to getting the query
  • SpreadsheetApp.openById(" paste here, your spread sheet id") is used to give spread sheet id which one saved in note pad
  • getSheetByName("sheet name") is used to get the sheet name
  • return the insert_data(e.sheet) is used to return the sheet
apps script doGet code for insert operation

insert_data is the one more function to do the insert operation in spread sheet which are coming from UI. below image has the code on insert operation.

insert operation in google apps script

Till now step one is completed. now we have to complete the step two. in step 2 we can find the html and ajax calls in javascript.

Step 2. create the html and ajax calls in java script.

below images show the html code and java script.

Insert operation on Spread Sheet using Google Apps script  html

Below code shows the Java script Code for HTML.
apps script javascript on insert operation
The Final Out put looks like below image

Request for code from Contact Form


No comments: