How to retrieve the very last row (empty or not) of a Google Sheet by script?

Viewed 49

I want to prepare a Google Sheet for being printed partially. So I have to hide the unused rows at the bottom:

lastUsedSheetRow = ownSheet.getLastRow();
LastSheetRow = ownSheet.XXXXX()?;
ownSheet.hideRows(lastUsedSheetRow + 1 , LastSheetRow - lastUsedSheetRow + 1);

//hideRows(<index of first row to hide>, <number of rows to hide>);

What do I have to do to get the "veryLastSheetRow" of a sheet?

2 Answers

getMaxRows()

Returns the current number of rows in the sheet, regardless of content.

Related