C# Open Excel Worksheets with IronXL

Open Excel worksheets in C# using IronXL's WorkBook.Load() and GetWorkSheet() methods to access any Excel file type (.xls, .csv, .tsv, .xlsx) and read or manipulate data with just two lines of code.

Learn how to use C# to open Excel worksheet functions for working with Excel spreadsheets and all file types including .xls, .csv, .tsv, and .xlsx. Opening an Excel worksheet, reading its data, and manipulating it programmatically are essential for many business applications. IronXL provides a streamlined approach that eliminates the need for Excel Interop, offering a solution with fewer lines of code and faster response times.

Quickstart: Load a Workbook and Open a Worksheet in One Line

Just two simple method calls let you load any supported Excel file and open a named worksheet—no complex setup or interop required. IronXL makes it simple to start reading or editing data immediately.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. Copy and run this code snippet.

    WorkBook wb = WorkBook.Load("sample.xlsx"); WorkSheet ws = wb.GetWorkSheet("Sheet1");
  3. Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

Minimal Workflow (5 Steps)

  • Install C# library to open Excel files
  • Load the Excel file into WorkBook object
  • Explore many ways to select WorkSheet from the opened Excel file
  • Access cell data via the selected WorkSheet object
  • Get data from rows and columns range
How To Work related to C# Open Excel Worksheets with IronXL

Step 1

How Do I Access the Excel C# Library?

Access the Excel C# Library via DLL or install it using your preferred NuGet manager. Once you've accessed the IronXL library and added it to your project, you can use all the functions below to open Excel worksheets in C#. For detailed installation instructions and system requirements, consult the IronXL documentation.

Install-Package IronXL.Excel

IronXL supports deployment across multiple platforms including Linux, macOS, and Docker containers, making it versatile for various development environments.


How to Tutorial

How Do I Load an Excel File?

Use the WorkBook.Load() function from IronXL to load Excel files into the project. This function requires a string parameter, which is the path of the Excel file to be opened. IronXL supports loading various spreadsheet formats including XLS, XLSX, CSV, TSV, and more. For comprehensive guidance on loading different file types, see the load spreadsheet tutorial.

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-load-workbook.cs
using IronXL;

// Get a worksheet by its name
WorkSheet workSheet = workBook.GetWorkSheet("SheetName");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

The Excel file at the specified path will load into the workBook object. Now, specify the Excel worksheet to open. The WorkBookLoadOptions parameter allows you to handle password-protected workbooks and control formula recalculation behavior.


How Do I Open an Excel WorkSheet?

To open a specific WorkSheet of an Excel file, IronXL provides the WorkBook.GetWorkSheet() function. Use it to open the worksheet by its name:

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-get-worksheet.cs
// Get a worksheet by its name
WorkSheet workSheet = workBook.GetWorkSheet("SheetName");
' Get a worksheet by its name
Dim workSheet As WorkSheet = workBook.GetWorkSheet("SheetName")
$vbLabelText   $csharpLabel

The specified WorkSheet will open in workSheet with all its data. There are several other ways to open a specific WorkSheet of an Excel file:

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-multiple-open.cs
using IronXL;
using System.Linq;

// Open by sheet index
WorkSheet workSheet = workBook.WorkSheets[0];

// Open the default worksheet
WorkSheet workSheet2 = workBook.DefaultWorkSheet;

// Open the first sheet
WorkSheet workSheet3 = workBook.WorkSheets.First();

// Open the first or default sheet
WorkSheet workSheet4 = workBook.WorkSheets.FirstOrDefault();
Imports IronXL
Imports System.Linq

' Open by sheet index
Private workSheet As WorkSheet = workBook.WorkSheets(0)

' Open the default worksheet
Private workSheet2 As WorkSheet = workBook.DefaultWorkSheet

' Open the first sheet
Private workSheet3 As WorkSheet = workBook.WorkSheets.First()

' Open the first or default sheet
Private workSheet4 As WorkSheet = workBook.WorkSheets.FirstOrDefault()
$vbLabelText   $csharpLabel

For more advanced worksheet management tasks like adding, renaming, or deleting worksheets, refer to the manage worksheet guide.

Now, get data from the opened Excel WorkSheet.


How Do I Get Data from a WorkSheet?

Get data from an opened Excel WorkSheet in the following ways:

  1. Get a specific cell value of Excel WorkSheet.
  2. Get data in a specific Range.
  3. Get all the data from WorkSheet.
  4. Export data to other formats.

Let's examine how to get data in different ways with these examples:

How Do I Get Specific Cell Values?

The first approach to getting data from an Excel WorkSheet is to get specific cell values. Access them like this:

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-cell-address.cs
// Access a specific cell value by its address
string val = workSheet["Cell Address"].ToString();
' Access a specific cell value by its address
Dim val As String = workSheet("Cell Address").ToString()
$vbLabelText   $csharpLabel

workSheet is the WorkSheet of the Excel file, as shown in the following examples. Specific cell values can also be accessed by specifying row index and column index.

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-cell-row.cs
// Access a cell value by row index and column index
string val = workSheet.Rows[RowIndex].Columns[ColumnIndex].Value.ToString();
' Access a cell value by row index and column index
Dim val As String = workSheet.Rows(RowIndex).Columns(ColumnIndex).Value.ToString()
$vbLabelText   $csharpLabel

Here's an example of how to open an Excel file in your C# project and get specific cell values using both methods:

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-specified-cell.cs
using IronXL;
using System;

WorkBook workBook = WorkBook.Load("sample.xlsx");

// Open WorkSheet
WorkSheet workSheet = workBook.GetWorkSheet("Sheet1");

// Get value By Cell Address
int intValue = workSheet["C6"].Int32Value;

// Get value by Row and Column Address
string strValue = workSheet.Rows[3].Columns[1].Value.ToString();

Console.WriteLine("Getting Value by Cell Address: {0}", intValue);
Console.WriteLine("Getting Value by Row and Column Indexes: {0}", strValue);
Imports IronXL
Imports System

Private workBook As WorkBook = WorkBook.Load("sample.xlsx")

' Open WorkSheet
Private workSheet As WorkSheet = workBook.GetWorkSheet("Sheet1")

' Get value By Cell Address
Private intValue As Integer = workSheet("C6").Int32Value

' Get value by Row and Column Address
Private strValue As String = workSheet.Rows(3).Columns(1).Value.ToString()

Console.WriteLine("Getting Value by Cell Address: {0}", intValue)
Console.WriteLine("Getting Value by Row and Column Indexes: {0}", strValue)
$vbLabelText   $csharpLabel

This code displays the following output:

Console showing worksheet data retrieval: cell address returns 'Canada', row/column indexes return '90540'

Value of Excel file sample.xlsx in row [3].Column [1] and C6 cell:

Excel worksheet with business data table showing segments, countries, and values with highlighted cells

The rows and column indices start from 0.

Open Excel WorkSheets and get specific cell data, and you can read more about how to read Excel data in C# from already open Excel worksheets. For more examples on reading Excel files, check out the how to read Excel file tutorial.

How Do I Get Data from a Specific Range?

Now examine how to get data in a specific range from an opened Excel WorkSheet using IronXL. The select range functionality provides powerful options for data extraction.

IronXL provides an intelligent way to get data in a specific range. Specify from to to values:

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-select-range.cs
// Access data from a specific range
var rangeData = workSheet["From Cell Address : To Cell Address"];
' Access data from a specific range
Dim rangeData = workSheet("From Cell Address : To Cell Address")
$vbLabelText   $csharpLabel

Here's an example of using range to get data from an open Excel WorkSheet:

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-from-range.cs
using IronXL;
using System;

// Load Excel file
WorkBook workBook = WorkBook.Load("sample.xlsx");
WorkSheet workSheet = workBook.GetWorkSheet("Sheet1");

// Specify the range
foreach (var cell in workSheet["B2:B10"])
{
    Console.WriteLine("Value is: {0}", cell.Text);
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

The above code will pull data from B2 to B10 as follows:

Console output showing extracted country values from worksheet including Canada, Germany, Mexico, France, United States

The values of the Excel file sample.xlsx, from B2 to B10:

Excel spreadsheet with country data in column B highlighted, showing business segments and corresponding values

How Do I Get Data from a Row?

You can also describe a range for a specific row. For example:

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-select-row-range.cs
var rowData = workSheet["A1:E1"];
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

This will display all values from A1 to E1. Read more about C# Excel Ranges and how to work with different row and column identifications.

How Do I Get All Data from a WorkSheet?

Getting all the cell data from the open Excel WorkSheet is easy using IronXL. For this task, access each cell value by row and column indexes. You can also export the entire worksheet to various formats like CSV, JSON, or XML for easier processing. See the following example, which traverses all WorkSheet cells and accesses their values.

In this example, two loops work together: one traverses each row of the Excel WorkSheet and the other traverses each column of a specific row. This way, each cell value is easily accessed.

:path=/static-assets/excel/content-code-examples/how-to/c-sharp-open-excel-worksheet-all.cs
using IronXL;
using System;
using System.Linq;

// Load Excel file
WorkBook workBook = WorkBook.Load("sample2.xlsx");
WorkSheet workSheet = workBook.GetWorkSheet("Sheet1");

// Access all rows of the open Excel WorkSheet
for (int i = 0; i < workSheet.Rows.Count(); i++)
{
    // Access all columns of a specific row
    for (int j = 0; j < workSheet.Columns.Count(); j++)
    {
        // Access each cell for the specified column
        Console.WriteLine(workSheet.Rows[i].Columns[j].Value.ToString());
    }
}
Imports IronXL
Imports System
Imports System.Linq

' Load Excel file
Private workBook As WorkBook = WorkBook.Load("sample2.xlsx")
Private workSheet As WorkSheet = workBook.GetWorkSheet("Sheet1")

' Access all rows of the open Excel WorkSheet
For i As Integer = 0 To workSheet.Rows.Count() - 1
	' Access all columns of a specific row
	For j As Integer = 0 To workSheet.Columns.Count() - 1
		' Access each cell for the specified column
		Console.WriteLine(workSheet.Rows(i).Columns(j).Value.ToString())
	Next j
Next i
$vbLabelText   $csharpLabel

The output of the above code will display each cell value of the complete open Excel WorkSheet. For working with larger datasets, consider using IronXL's DataSet and DataTable export functionality for better performance and memory management.


Tutorial Quick Access

Documentation related to Tutorial Quick Access

API Reference Resource

Use the IronXL API Reference resource as your guide to all functions and classes for use in your projects, as well as namespaces, method fields, enums, and feature sets.

API Reference Resource

Frequently Asked Questions

How do I open an Excel worksheet in C# without Microsoft Office installed?

IronXL provides a simple solution using WorkBook.Load() and GetWorkSheet() methods. With just two lines of code, you can open any Excel file (.xls, .xlsx, .csv, .tsv) without requiring Excel Interop or Microsoft Office installation on your system.

What file formats are supported when opening Excel worksheets?

IronXL supports multiple spreadsheet formats including .xls (older Excel format), .xlsx (modern Excel format), .csv (comma-separated values), and .tsv (tab-separated values). The WorkBook.Load() function automatically handles all these formats seamlessly.

Can I deploy my Excel worksheet application on Linux or macOS?

Yes, IronXL supports cross-platform deployment including Linux, macOS, and Docker containers. This makes it versatile for various development environments beyond Windows, eliminating platform-specific limitations.

How do I install the Excel C# library for my project?

You can access IronXL through a DLL download or install it via NuGet package manager. The library provides comprehensive documentation for detailed installation instructions and system requirements to get started quickly.

What's the basic code to load an Excel file and access a specific worksheet?

Simply use two lines: WorkBook wb = WorkBook.Load("sample.xlsx"); WorkSheet ws = wb.GetWorkSheet("Sheet1"); This loads your Excel file and opens the named worksheet for immediate data access and manipulation.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 1,753,501 | Version: 2025.12 just released