IRONSOFTWAREHOME

How to Load Existing Spreadsheets in C#

Curtis Chau
Curtis Chau
Updated: August 2, 2026

Load existing Excel, CSV, TSV files and objects into C# spreadsheets using IronXL's WorkBook.Load() method for full Excel support or LoadCSV() for CSV formats, enabling seamless data manipulation and extraction in .NET applications.

using IronXL;

// Load CSV file
WorkBook workBook = WorkBook.LoadCSV("sample.csv");

CSV (Comma-Separated Values) file format is for tabular data where values are separated by commas, commonly used for data exchange. TSV (Tab-Separated Values) uses tabs to separate values, preferred when data contains commas. Learn more about converting between file formats.

The DataSet class in Microsoft's .NET is part of the ADO.NET (ActiveX Data Objects for .NET) technology. It's often used in database-related applications and allows you to work with data from various sources like databases, XML, and more. IronXL provides seamless integration for importing and exporting DataSet objects.

Data contained in Excel file formats such as XLSX, XLS, XLSM, XLTX, CSV, and TSV as well as DataSet objects can be loaded into an Excel spreadsheet using IronXL. This powerful capability makes IronXL an essential tool for developers working with spreadsheet data in business applications, data analysis projects, and automated reporting systems.

Quickstart: Load an Existing Spreadsheet

Using one simple method, you can load an existing Excel, CSV, or TSV file into a WorkBook with IronXL. Developers can quickly get started editing or extracting data by calling WorkBook.Load(...) for full Excel support, or LoadCSV(...) specifically for CSV formats. For comprehensive API documentation, visit the IronXL API Reference.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    IronXL.WorkBook workbook = IronXL.WorkBook.Load("sample.xlsx");
    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 Load Excel Spreadsheet Files in C#?

Use the static method Load to load an existing Excel workbook. The method supports XLSX, XLS, XLSM, XLTX, CSV, and TSV file formats. When the workbook is protected with a password, pass the password as the second parameter to the method. The method also accepts workbook data as a byte array or stream, where the dedicated FromByteArray and FromStream methods can be used, respectively.

IronXL's loading capabilities are designed to handle various scenarios in real-world applications. Whether you're processing files uploaded by users, reading from network streams, or working with encrypted documents, the library provides a consistent and reliable interface. The Load method automatically detects the file format based on the file extension and content, making it versatile for different use cases.

Which File Formats Can I Load?

using IronXL;

// Supported for XLSX, XLS, XLSM, XLTX, CSV and TSV
WorkBook workBook = WorkBook.Load("sample.xlsx");

The flexibility to load multiple file formats means you can work with legacy Excel files (XLS), modern Excel workbooks (XLSX), macro-enabled workbooks (XLSM), and template files (XLTX). This compatibility ensures smooth migration from older systems while supporting modern Excel features. For more details on creating new spreadsheets, check out our comprehensive guide.

How Do I Handle Password-Protected Files?

Working with sensitive data often requires password protection. IronXL makes it simple to load password-protected workbooks by providing the password as a parameter:

// Load password-protected Excel file
WorkBook protectedWorkBook = WorkBook.Load("protected.xlsx", "myPassword123");

// Work with the workbook normally
WorkSheet sheet = protectedWorkBook.DefaultWorkSheet;
sheet["B2"].Value = "Updated secure data";

// Save with password protection
protectedWorkBook.SaveAs("updated_protected.xlsx");

What About Loading from Byte Arrays or Streams?

In modern applications, files often come from various sources like web uploads, API responses, or database BLOBs. IronXL handles these scenarios elegantly:

// Loading from byte array
byte[] excelBytes = File.ReadAllBytes("sample.xlsx");
WorkBook workBookFromBytes = WorkBook.FromByteArray(excelBytes);

// Loading from stream
using (FileStream stream = new FileStream("sample.xlsx", FileMode.Open))
{
    WorkBook workBookFromStream = WorkBook.FromStream(stream);
    
    // Process the workbook
    var sheet = workBookFromStream.DefaultWorkSheet;
    Console.WriteLine($"Sheet has {sheet.RowCount} rows");
}

// Loading from MemoryStream (common in web applications)
using (MemoryStream memStream = new MemoryStream(excelBytes))
{
    WorkBook workBookFromMemory = WorkBook.FromStream(memStream);
}

Why Should I Use a Dedicated Method for CSV Files?

While the Load method can read all available file formats, use the LoadCSV method specifically for CSV file formats for optimal handling. CSV files have unique characteristics that benefit from specialized processing, such as delimiter detection, encoding handling, and data type inference. It's particularly useful when dealing with international data formats or when CSV files use non-standard delimiters like semicolons or pipes.

When Is LoadCSV Better Than Load?

The LoadCSV method provides enhanced control over CSV parsing, making it ideal when you need to specify custom delimiters, handle different encodings, or work with large CSV files. It's particularly useful when dealing with international data formats or when CSV files use non-standard delimiters like semicolons or pipes.

How Does LoadCSV Handle Special Characters?

The LoadCSV method automatically handles various encodings including UTF-8, UTF-16, and ASCII, ensuring that special characters, accented letters, and international symbols are preserved correctly. This is crucial when working with multilingual data or scientific notation. Learn more about writing CSV files in .NET for complete CSV workflow management.


How Can I Load DataSet Objects into Excel?

The DataSet class in Microsoft .NET is used for managing and working with data in a disconnected, in-memory representation. This DataSet can be loaded into the workbook using the LoadWorkSheetsFromDataSet method. In the code example below, an empty DataSet is created; however, it's more common to instantiate the DataSet from a database query.

Why Would I Convert DataSet to Excel?

Converting DataSet objects to Excel format is essential for reporting, data export, and creating user-friendly data presentations. Business users often prefer Excel formats for data analysis, and automated reports frequently need to transform database results into spreadsheet formats. This conversion enables features like conditional formatting, chart creation, and formula application that aren't available in raw DataSet objects.

What Happens to DataSet Relationships in Excel?

When loading a DataSet with multiple related tables, IronXL creates separate worksheets for each DataTable in the DataSet. Table relationships are preserved through consistent key values, allowing users to maintain data integrity when working with the exported Excel file. This makes it ideal for exporting complex database schemas while maintaining referential integrity.

Can I Load Multiple Tables from DataSet?

using IronXL;
using System.Data;

// Create dataset
DataSet dataSet = new DataSet();

// Create workbook
WorkBook workBook = WorkBook.Create();

// Load DataSet
WorkBook.LoadWorkSheetsFromDataSet(dataSet, workBook);

For more advanced scenarios involving database integration, explore our guide on Excel to SQL via System.Data.DataSet which demonstrates bidirectional data flow between Excel and databases.

The ability to load various data sources into Excel format makes IronXL an invaluable tool for .NET developers. Whether you're building reporting systems, data migration tools, or business intelligence applications, the loading capabilities provide the foundation for powerful spreadsheet manipulation. For more examples and advanced techniques, visit our comprehensive tutorials section.

Frequently Asked Questions

How do I load an existing Excel file in C# using IronXL?

To load an existing Excel file in C#, use the `WorkBook.Load()` method provided by IronXL. This method supports a variety of formats including XLSX, XLS, XLSM, XLTX, CSV, and TSV.

Can IronXL handle loading CSV files specifically?

Yes, while IronXL's `WorkBook.Load()` method can load various formats, it's recommended to use the `LoadCSV()` method specifically for CSV files due to its enhanced control over CSV parsing, such as delimiter detection and encoding handling.

How does IronXL support loading password-protected Excel files?

IronXL allows loading of password-protected Excel files by passing the password as the second parameter to the `WorkBook.Load()` method, enabling secure handling and manipulation of sensitive data.

What file formats are supported by IronXL's loading capabilities?

IronXL supports loading multiple file formats including XLSX, XLS, XLSM, XLTX, CSV, and TSV, ensuring compatibility with both legacy and modern Excel features.

Can IronXL load Excel files from byte arrays or streams?

Yes, IronXL can load Excel files from byte arrays using the `FromByteArray` method and from streams using the `FromStream` method. This is useful for files obtained from web uploads, API responses, or database BLOBs.

How can `DataSet` objects be loaded into Excel using IronXL?

You can load `DataSet` objects into Excel using the `LoadWorkSheetsFromDataSet` method in IronXL, which is useful for data reporting and exporting database results to spreadsheet formats.

Does IronXL have a dedicated method for loading Excel files with non-standard delimiters?

Yes, IronXL's `LoadCSV` method is specifically designed to handle different delimiters, making it ideal for CSV files that utilize semicolons or pipes instead of the standard comma.

Why is it beneficial to convert `DataSet` objects to Excel format?

Converting `DataSet` objects to Excel format using IronXL facilitates reporting, data export, and data presentation, allowing users to leverage Excel's features like conditional formatting, charts, and formulas.

Can IronXL preserve relationships between tables in a `DataSet`?

Yes, when loading a `DataSet` with multiple related tables using IronXL, separate worksheets are created, and table relationships are maintained through consistent key values.

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