Last active
April 23, 2024 22:02
-
-
Save Max-Makhrov/62b76a6799e0b498ab032e20f9f73f40 to your computer and use it in GitHub Desktop.
Get all elements of data from Google Sheets Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDataElementsFromSheet() | |
{ | |
var sheet = SpreadsheetApp.getActiveSheet(); // get active sheet | |
var range = sheet.getDataRange(); // get range object containing data | |
var data = range.getValues(); // write range data into array called data | |
getDataElements(data); // To see the result run function and press <Ctrl + Enter> | |
} | |
function getDataElements(data) | |
{ | |
var h = data.length; // get number of rows | |
var l = data[0].length; // get number of columns | |
var row = []; // define empty array to store rows | |
// loop rows of data | |
for (var i = 0; i < h; i++) | |
{ | |
// get single row data inside an array | |
row = data[i]; | |
// loop the row | |
for (var j = 0; j < l; j++) | |
{ | |
// row[j] -- is a value of a single data element | |
Logger.log(row[j]); // use any operation here. | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment