DEV Community

IronSoftware
IronSoftware

Posted on • Originally published at ironsoftware.com

1 1

Select Excel Range

IronXL allows us to easily select and work with ranges in any Excel WorkSheet.

C#:

using System.Linq;
using IronXL;

WorkBook workbook = WorkBook.Load("test.xls");
WorkSheet sheet = workbook.WorkSheets.First();

//This is how we get range from Excel worksheet
var range = sheet["A2:A8"];

//This is how we can iterate over our range
foreach (var cell in range)
{
    Console.WriteLine(cell.Value);
}
Enter fullscreen mode Exit fullscreen mode

VB:

Imports System.Linq
Imports IronXL

Private workbook As WorkBook = WorkBook.Load("test.xls")
Private sheet As WorkSheet = workbook.WorkSheets.First()

'This is how we get range from Excel worksheet
Private range = sheet("A2:A8")

'This is how we can iterate over our range
For Each cell In range
    Console.WriteLine(cell.Value)
Next cell
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay