IRONSOFTWAREHOME

C# Open Excel Worksheets with IronXL

Curtis Chau
Curtis Chau
Updated: August 2, 2026

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.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

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

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


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.

PM > Install-Package IronXL.Excel

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


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.

using IronXL;

// Get a worksheet by its name
WorkSheet workSheet = workBook.GetWorkSheet("SheetName");

The Excel file at the specified path will load into the workBook object. Now, specify the Excel worksheet to open. The LoadingOptions parameter allows you to handle password-protected workbooks via its Password property.


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:

// Get a worksheet by its name
WorkSheet workSheet = workBook.GetWorkSheet("SheetName");

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:

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();

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:

// Access a specific cell value by its address
string val = workSheet["Cell Address"].ToString();

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.

// Access a cell value by row index and column index
string val = workSheet.Rows[RowIndex].Columns[ColumnIndex].Value.ToString();

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

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);

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:

// Access data from a specific range
var rangeData = workSheet["From Cell Address : To Cell Address"];

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

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);
}

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:

var rowData = workSheet["A1:E1"];

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.

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());
    }
}

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.

Frequently Asked Questions

How can I open an Excel worksheet in C# using IronXL?

To open an Excel worksheet in C#, you can use IronXL's WorkBook.Load() method to load the file and the GetWorkSheet() method to open a specific sheet. This allows you to access and manipulate Excel data with minimal code.

What file formats are supported by IronXL for opening Excel worksheets?

IronXL supports a variety of file formats including .xls, .xlsx, .csv, and .tsv for opening Excel worksheets, making it versatile for handling different spreadsheet types.

Can I access specific cell values using IronXL?

Yes, IronXL allows you to access specific cell values by using the address of the cell or by specifying the row and column indices. This functionality makes it easy to retrieve and manipulate specific data points.

How can I extract data from a range of cells in an Excel worksheet using IronXL?

To extract data from a range of cells, IronXL provides functionality to specify a range using cell addresses. You can retrieve all data within that range efficiently.

Is it possible to work with entire rows or columns using IronXL?

Yes, IronXL provides the flexibility to work with entire rows or columns, allowing you to access data or perform operations on them as needed.

Can IronXL handle password-protected Excel workbooks?

IronXL supports loading password-protected workbooks through its LoadingOptions parameter, which allows you to specify the password when opening the workbook.

How do I install IronXL to start working with Excel worksheets in C#?

You can install IronXL via the NuGet package manager by searching for IronXL.Excel or by downloading the library directly from Iron Software's website.

What platforms are supported by IronXL for Excel operations?

IronXL supports a wide range of platforms including Windows, Linux, macOS, and even Docker containers, making it adaptable for various development environments.

How does IronXL compare to using Excel Interop for C# applications?

IronXL provides a more streamlined approach compared to Excel Interop by requiring fewer lines of code, offering faster performance, and eliminating dependencies on Excel installations.

Can I export data from an Excel worksheet to other formats using IronXL?

Yes, IronXL allows you to export data from an Excel worksheet to formats like CSV, JSON, or XML, enabling easier data handling and integration with other systems.

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 2,237,574Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

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