I want to fetch the range of all cells with data in it, but not including the header row.
I found that getDataRange() captures all the cells with data in it, and to avoid including the first row, I thought I could just delete the first element in what I am assuming is an array?
How can I do this/ is there a more elegant way to approach this problem?
getDataRange()
.If my understanding is correct, how about this sample script? Please think of this as just one of several answers.
In this sample, offset()
is used. In this case, before the values are retrieved, the range is modified.
var sheet = SpreadsheetApp.getActiveSheet();
var headerRowNumber = 1;
var values = sheet.getDataRange().offset(headerRowNumber, 0, sheet.getLastRow() - headerRowNumber).getValues();
Logger.log(values)
In this sample, shift()
is used. In this case, after the values were retrieved, the values are modified.
var sheet = SpreadsheetApp.getActiveSheet();
var values = sheet.getDataRange().getValues();
values.shift();
Logger.log(values)
If I misunderstood your question and this was not the direction you want, I apologize.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With