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?
The LastRowUsed()
function returns a row object. Use
worksheet.LastRowUsed().RowNumber()
to get the number of the last row used.
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