Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClosedXML find last row number

I'm using ClosedXML with C# to modify an Excel workbook. I need to find the last row number used but .RowCount() counts how many rows are in the worksheet. So it is returning 1 million rows when there are only a few thousand. I have tried LastRowUsed() but that doesn't return an int and there is no .row method for it. How can I get the last row in an int?

like image 518
Daniel Blois Avatar asked Jan 31 '17 21:01

Daniel Blois


1 Answers

The LastRowUsed() function returns a row object. Use

worksheet.LastRowUsed().RowNumber()

to get the number of the last row used.

like image 57
Raidri Avatar answered Sep 17 '22 21:09

Raidri