I am getting the data range of a sheet and using Range.getNumRows()
to get the number of rows in a Google Spreadsheet using Google Apps Script.
But when the sheet happens to be completely empty, Range.getNumRows()
still returns 1 instead of 0. I am guessing this is because a range has to have at least 1 cell.
Is there another (simple) way to get the number of rows in a sheet without having this Problem?
I know I could loop through all cells in the sheet to check it is completely empty, but this doesn't seem very efficient.