how to get EPPlus OpenXML row count (c#)

前端 未结 5 1726
无人共我
无人共我 2021-01-17 09:49

I searched for it and found the link C# EPPlus OpenXML count rows

int iRowCount = currentWorksheet.Dimension.End.Row - currentWorksheet.Dimension.Start.Row;
         


        
5条回答
  •  没有蜡笔的小新
    2021-01-17 10:03

    There is a way to get the cells that don't have no value using the Where method. We can use it to find the very last cell (and its row in this case) from a worksheet, or a range.

    int lastRow = sheet.Cells.Where(cell => !cell.Value.ToString().Equals("")).Last().End.Row;
    

    About the Where method : https://msdn.microsoft.com/en-us/library/bb534803(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1

提交回复
热议问题