Fetch Data from Google Spreadsheet – Hello, This is the 6th Google Apps Script tutorial in which I will show how to fetch data from Google Spreadsheet into Form fields. In the 5th part of Google Apps Scripting How to series, I have shared information about writing data into Google Spreadsheet. In this post, I will show How to Fetch Data from Google Spreadsheet into Google Form Fields.
Read Also:
- Create Custom Menu, Call Function and Send Customized Mail from Spreadsheet
- Google Script to Write Data in Spreadsheet
- Google Script to Send Email
- Google Script to Create GUI Application
Fetch Data from Google Spreadsheet File
It is very simple to fetch data from Google Spreadsheet in Google Form Fields. In this tutorial I will show how to fetch particular record like based on primary key just like in any other database. See the Spreadsheet below in which User Id column is used to store unique key value.
In the earlier post I have already shown how to create UI Application using Google Apps Scripting. Now you just need to add one more textbox and label which will be used as search box.
Trick to Fetch the data from Google Spreadsheet is very simple, all you need to do is find the required row id. Data in Spreadsheet is stored just like 2D Array. Suppose if the user searches for “a001” user id then it is row 2 of the sheet. And to display the value of corresponding Name in the text box you have to set its value with sheetdata[2][1]. Where [2] means the data is in second row and [1] means value of first column.
Complete Code to Fetch Data from Google SpreadSheet
Try this and comment below for when of any problems.
I face this error “The script completed but did not return anything.”. I don’t how is accured.
i am tying to fetch data as json object.i did it.But facing problem when sheet size is very large(7000 rows).how can i solve it?please help