How to access and read data off of spreadsheets

Today we learned how to access specific data on a specific spreadsheet. To do this you have to think of the spreadsheet in multiple layers. The first of which is the actual document which is represented by a link or ID.

Below: This Line of code is how you access through a variable the first layer of the spreadsheet.

Screen Shot 2016-05-11 at 7.40.12 amThen you have to access the specific spreadsheet on the doc.

Below: These are just examples of the number of different spreadsheets that I am using for my project.Screen Shot 2016-05-11 at 7.41.50 am

In the above picture there are 16 different spreadsheets all in one doc and I only want to access one. This is where you use .getSheetByName which allows you to select one specific sheet.

Below: This is the code that allows you to access through a variable the one spreadsheet.

Screen Shot 2016-05-11 at 7.47.48 am

 

 

 

This code uses the variable activeSheet to store the data from sheet “New” so it can be accessed later in the document. There is another variable in this code which is spreadSheet, this is where I stored the whole doc.

Below: This code accesses the specific box “D2”, inside the spreadsheet “New”.

Screen Shot 2016-05-11 at 7.53.04 am

 

 

 

This is the final layer of the document where I can access the data that is inside the specific box “D2”, then can log this data using the Logger.log function and the variable or var cellD2.

 

 

Leave a Reply