Last cell in row and column in Epplus - C#
An important thing to know about the Cells object in an Worksheet in EPPlus is that it contains only references to cell that have data added to it. So with a little bit of LINQ you can get the address of every "Row" like this:
var lastRowCell1 = worksheet.Cells.Last(c => c.Start.Row == 1);
var lastRowCell2 = worksheet.Cells.Last(c => c.Start.Row == 2);
var lastColCell1 = worksheet.Cells.Last(c => c.Start.Column == 1);
var lastColCell2 = worksheet.Cells.Last(c => c.Start.Column == 2);
To get the last Cell's index you can use worksheet.Dimension
:
int numCol = worksheet.Dimension.Rows;
int numCol = worksheet.Dimension.Columns;
If you want the last address of Column or Row you can use this:
String lastAddress = worksheet.Dimension.Address.Last().ToString();