Document Solutions for Excel, .NET Edition | Document Solutions
Features / Worksheet / Range Operations / Get Row and Column Count
In This Topic
    Get Row and Column Count
    In This Topic

    In a large worksheet, manually fetching the number of rows and columns can be a tedious task.

    DsExcel allows users to quickly get the row and column count of the specific areas or all the areas in a range.

    The Count property of the IRange interface represents the cell count of all the areas in a range.

    Refer to the following example code in order to get the row count and column count in a worksheet.

    C#
    Copy Code
    var range = worksheet.Range["A5:B7"];
    
    //cell count is 6.
    var cellcount = range.Count;
    //cell count is 6.
    var cellcount1 = range.Cells.Count;
    //row count is 3.
    var rowcount = range.Rows.Count;
    //column count is 2.
    var columncount = range.Columns.Count;