Last cell line and column Epplus - C #

3

I want to select a range from the first to the last cell filled in the row or column. In VBA the code stays as below using

Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select

How could I do it the same way in C # using Epplus? I will start from cell B139 and I need to go to the last row and column filled

    
asked by anonymous 02.03.2017 / 17:41

2 answers

2

Thank you for your attention. I was able to find the answer using LINQ

To line

 var lastRowCell1 = worksheet.Cells.Last(c => c.Start.Row == 1);

For Column

 var lastColCell1 = worksheet.Cells.Last(c => c.Start.Column == 1);
    
08.03.2017 / 19:02
2

I do not know much about the Epplus package, but it seems to solve the problem using:

using (ExcelPackage xlPackage = new ExcelPackage(newFile)) 
{
   ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
}

var rowCnt = worksheet.Dimension.End.Row;
var colCnt = worksheet.Dimension.End.Column;
    
06.03.2017 / 22:45