Skip to main content Skip to footer

Get Last Column or Row Containing Data

To get the last row or column of a worksheet containing data, we can use the GetUsedRange method. We will also set the UsedRangeType to Data, but this can be changed to look for other members instead, like pictures.

Refer to the following code snippet that shows how this can be accomplished:

IRange usedDataRange = WorksheetInstance.GetUsedRange(type: UsedRangeType.Data);
int lastRow = usedDataRange.LastRow + 1;
int lastColumn = usedDataRange.LastColumn + 1;

Tye Glenz