Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get data from row into an array

a really quick question... I want to read rows in sheets one by one, (preferably 'live' so rather than putting it in an array or something). Besides using a loop, how do I read the contents of a whole row? Is it even possible?

like image 732
stretch Avatar asked May 16 '26 16:05

stretch


2 Answers

You can read about it here

function readData() {
  var sht = SpreadsheetApp.getActiveSheet();
  var rng = sht.getRange(rownumber, 1, 1, numberofcolums)
  var rangeArray = rng.getValues();
//now all your data for that row is in a two Dimensional array [[1,2,3,4,'My Data','etc']]  

}
like image 109
Cooper Avatar answered May 18 '26 04:05

Cooper


var
  spreadsheetID =
    "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
  rowNum = 1,
  rowVals =
    SpreadsheetApp.openById(spreadsheetID)
    .getRange(rowNum +":"+ rowNum)
    .getValues()
;

The other answers to date don't get a row, they get a range of specfic columns within a row. The code in this answer gets the entire unbounded row.

like image 33
Matthew Avatar answered May 18 '26 04:05

Matthew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!