IRONSOFTWAREHOME
USING IRONXL

How to Load An Excel File in C#

Curtis Chau
Curtis Chau
Updated: August 1, 2026

To load Excel files in C#, use the IronXL library's WorkBook.Load() method which accepts file paths, streams, or byte arrays, then access worksheets and read cell values programmatically without requiring Microsoft Office installation.

This article will demonstrate how to load Excel files using IronXL, a comprehensive Excel C# library, efficiently and programmatically. Whether you're building ASP.NET MVC applications that read Excel files or creating Windows Forms Excel readers, IronXL provides a simple yet powerful solution.

How to Load Excel Files

  1. Open Visual Studio and create a new Visual Studio project.
  2. Download the IronXL NuGet package library.
  3. Make an Excel workbook in XLSX file or CSV file format.
  4. Now load the Excel file using the IronXL Library.
  5. Process the Excel values using the cell range.

What Is IronXL and Why Should I Use It?

What is IronXL?

The C# .NET Excel library, IronXL, can be used to read data from and convert Microsoft Excel documents to CSV files. No Microsoft Office, Microsoft.Office.Interop.Excel, or Excel Interop installation is required for IronXL. It is a completely independent .NET Excel application library that works seamlessly with Docker containers and can be deployed to AWS Lambda functions or Azure cloud services. Numerous spreadsheet formats can be read by it.

Excel spreadsheets in a .NET context may be easily generated, modified, and viewed thanks to IronXL's straightforward C# API. Core .NET apps, Linux environments, macOS systems, Azure, and Xamarin are all fully supported by IronXL. The library also integrates smoothly with Blazor applications for reading Excel files and .NET MAUI projects. Below is a bulleted list of IronXL's key features that set it apart from other applications for reading Excel files.

What Are the Key Features That Make IronXL Stand Out?

Why Should I Choose IronXL Over Other Excel Libraries?

With these features, IronXL becomes a flexible and strong library for working with Excel files, giving developers more convenience and flexibility when managing their Excel document-related tasks programmatically. The library provides comprehensive API reference documentation and extensive tutorials to help developers get started quickly. To know more about the IronXL library, refer to those documents.

How Do I Set Up a .NET Project for Excel File Operations?

The IronXL library makes it easy to write data and create and read Excel files, as you will see in the upcoming sections. Before we begin, ensure you have properly configured your license key if you're using the full version, or you can start with a free trial. For web applications, you may need to set up the license key in your web.config file.

First, let's start a new project for working with Excel files:

How Do I Create a New Project in Visual Studio?

Choose "New Project" from the "File" menu once Visual Studio has launched.

The .NET "Console App" project templates will appear in the dialog box that follows; select them and double-click on "Next."

Visual Studio 'Add a new project' dialog showing various C# project templates including Console App, ASP.NET Core Web App, Blazer Server App, and ASP.NET Core Web API. New Project

What Project Settings Should I Configure?

You can type any project name you want for the Project after entering the new project's location in the Location area. For this tutorial, consider naming it something descriptive like "ExcelReaderApp" or "IronXLDemo". Press the Next button to continue.

Visual Studio new project configuration dialog showing options for creating a C# Console App with empty fields for project name 'ExcelReaderApp' and a typical project location path. Project Configuration

Which .NET Framework Version Should I Select?

With the Framework drop-down menu, you can choose a .NET Framework. The long-term supported version of .NET, 6.0, is being used here. IronXL supports multiple .NET versions, so you can choose based on your project requirements. Hit "Create" after that.

Visual Studio project configuration screen showing Console App settings with .NET 6.0 highlighted as the selected framework. The 'Do not use top-level statements' checkbox is clearly visible and unchecked. Target framework Selection

How Do I Install the IronXL Library?

The following solution requires the IronXL library, which you should obtain. To accomplish this, input the below command into the Package Manager Console:

PM > Install-Package IronXL.Excel

Package Manager Console window in Visual Studio showing the successful installation of 'Install-Package IronXl.Excel' command with installation progress and confirmation messages displayed. IronXL Installation

An alternative to this would be to use the NuGet Package Manager to search for the package "IronXL".

Browsing should result in a list of all NuGet packages linked to IronXL. Then, select the one needed and click the install button.

NuGet Package Manager window in Visual Studio highlighting the IronXL.Excel package with version 2023.4.13. The 'Install' button is prominently highlighted with an arrow pointing to it. NuGet Package Manager

How Can I Read Excel Files Using IronXL?

The following code allows you to load and read Excel files using IronXL. This example demonstrates the basic approach to reading Excel files without Interop.

using IronXL;
using System.Linq;

// Load the workbook with the name "Demo.xlsx".
WorkBook workBook = WorkBook.Load("Demo.xlsx");

// Access the first worksheet in the workbook.
WorkSheet sheet = workBook.WorkSheets.First();

// Iterate through the range of cells A2 to B10 and print each cell's address and text content.
foreach (var cell in sheet["A2:B10"])
{
    Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text);
}

What Does Each Part of the Code Do?

The first line of code, using IronXL;, is called to implement the library into this demo project, which makes the IronXL functionalities available.

Then load the existing Excel file, named "Demo.xlsx", using the method Load which is available in the WorkBook object.

The Load method accepts three types of inputs: a file name with the path, a stream, and byte arrays. In the above example, the method with the file name and the path is used to load the file.

How Do I Access Specific Worksheets and Cell Ranges?

To perform the read Excel file operation, we obtain the default WorkSheet by using the First() method to select the initial worksheet from the workbook's worksheet collection. You can also manage worksheets by accessing them by name or index.

Subsequently, the Excel worksheet range is selected using the worksheet object by specifying the cell range. The select range functionality allows you to work with specific cells, entire rows, or columns. It will then iterate through each of the cell values within the specified range (A2:B10) and display the value along with the cell address.

What Output Should I Expect from This Code?

Excel spreadsheet showing sample data (Customer Name, Order Date, Product, etc.) with a C# console window below displaying the cell references and values being read by the IronXL code. Output of Previous Code Example

The above example demonstrates loading an Excel file in C# and its resulting output when using IronXL. It utilizes Excel sheets by referencing the row and column index.

How Can I Handle Different Excel File Formats?

IronXL supports various Excel file formats beyond the standard XLSX. You can read XLSX files, work with older XLS formats, and even read CSV files using the same API. Here's an example of loading different file types:

// Load an XLSX file
WorkBook xlsxWorkbook = WorkBook.Load("data.xlsx");

// Load a CSV file
WorkBook csvWorkbook = WorkBook.LoadCSV("data.csv", delimiter: ",");

// Load an XLS file (older Excel format)
WorkBook xlsWorkbook = WorkBook.Load("legacy.xls");

// Load from a stream instead of a file path
using (FileStream stream = new FileStream("data.xlsx", FileMode.Open))
{
    WorkBook streamWorkbook = WorkBook.Load(stream);
}

To know more about coding with IronXL, refer to this example.

What Are the Next Steps After Loading Excel Files?

IronXL is a well-liked Excel add-on that works without the need for any extra external libraries. It has several uses and doesn't need to have Microsoft Excel installed.

All programmable duties involving Microsoft Excel documents can be fully resolved with IronXL. You can add and remove data, search and replace, combine and unmerge data tables or cells, sort strings or numbers, visualize a data table, and save files. Formula computations are also possible with IronXL using the edit formulas feature. You can also set cell data types and examine spreadsheet data with it. The ability to read and write CSV files available with IronXL is a necessity for working with Excel data.

Advanced Features to Explore

Once you've mastered loading Excel files, consider exploring these advanced features:

Want to try it yourself?

While IronXL offers a free trial, users can choose to upgrade to a paid membership for 1 year to receive updates and customer assistance. IronXL charges extra for security that allows for unfettered distribution. To find out more about the specifics of the pricing, see this licensing page.

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

Related Articles

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