IRONSOFTWAREHOME
Select Excel Range
using IronXL;
using System;
using System.Linq;

WorkBook workBook = WorkBook.Load("sample.xls");
WorkSheet workSheet = workBook.WorkSheets.First();

// Get range from worksheet
var range = workSheet["A2:A8"];

// Get column from worksheet
var columnA = workSheet.GetColumn(0);

// Get row from worksheet
var row1 = workSheet.GetRow(0);

// Iterate over the range
foreach (var cell in range)
{
    Console.WriteLine($"{cell.Value}");
}

// Select and print every row
var rows = workSheet.Rows;

foreach (var eachRow in rows)
{
    foreach (var cell in eachRow)
    {
        Console.Write($"  {cell.Value}  |");
    }
    Console.WriteLine($"");
}
Imports IronXL
Imports System
Imports System.Linq

Dim workBook As WorkBook = WorkBook.Load("sample.xls")
Dim workSheet As WorkSheet = workBook.WorkSheets.First()

' Get range from worksheet
Dim range = workSheet("A2:A8")

' Get column from worksheet
Dim columnA = workSheet.GetColumn(0)

' Get row from worksheet
Dim row1 = workSheet.GetRow(0)

' Iterate over the range
For Each cell In range
    Console.WriteLine($"{cell.Value}")
Next

' Select and print every row
Dim rows = workSheet.Rows

For Each eachRow In rows
    For Each cell In eachRow
        Console.Write($"  {cell.Value}  |")
    Next
    Console.WriteLine("")
Next
NuGet Download
PM > Install-Package IronXL.Excel
Select Excel Range

Select Excel Range

IronXL allows us to easily select and work with ranges in any Excel WorkSheet. The code below demonstrates how ranges, rows, and columns can be easily selected. With IronXL, it is possible to apply further sorting or calculations to this collection of data using methods such as SortAscending(), SortDescending(), Sum(), Max(), Min(), and Avg(). However, be mindful that when applying methods that modify or move the value of a cell, the affected range, row, and column will also update their values accordingly.

Range

To select a range from A2 to A8, use var range = sheet["A2:A8"].

Row

To select row 1, use the method GetRow(0). The indexing follows zero-based numbering. The range of cells will be determined by the union of the populated cells of all the rows, including row 1 itself.

Column

To select column A, use the method GetColumn(0) or assign the range address as sheet["A:A"]. The range of cells will be determined by the union of the populated cells of all columns, including column A itself.

How to select Excel Range in C#

  1. Install C# library to select Excel range
  2. Load an existing or generate a new Excel workbook
  3. Select the targeted worksheet from the workbook
  4. Use sheet["A2:A8"] to select a range from A2 to A8
  5. Use GetColumn and GetRow methods to select individual columns and rows
Explore How to Select Excel Ranges with C# and IronXL.
View on GitHub

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required