How to Load Existing Spreadsheets

CSV (Comma-Separated Values) file format is for tabular data where values are separated by commas, commonly used for data exchange. On the other hand, TSV (Tab-Separated Values) uses tabs to separate values, preferred when data contains commas.

The DataSet class in Microsoft's .NET is a 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.

Data contained in Excel file formats such as XLSX, XLS, XLSM, XLTX, CSV, and TSV as well as a DataSet object can be loaded into an Excel spreadsheet using IronXL.


Get started with IronXL

Start using IronXL in your project today with a free trial.

First Step:
green arrow pointer


Load Spreadsheet Example

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

:path=/static-assets/excel/content-code-examples/how-to/load-spreadsheet-load-spreadsheet.cs
using IronXL;

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

' Supported for XLSX, XLS, XLSM, XLTX, CSV and TSV
Private workBook As WorkBook = WorkBook.Load("sample.xlsx")
$vbLabelText   $csharpLabel

Load CSV file

While the Load method can read all available file formats, it is recommended to use the LoadCSV method specifically for CSV file formats for optimal handling.

:path=/static-assets/excel/content-code-examples/how-to/load-spreadsheet-load-csv.cs
using IronXL;

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

' Load CSV file
Private workBook As WorkBook = WorkBook.LoadCSV("sample.csv")
$vbLabelText   $csharpLabel

Load DataSet

The DataSet class in Microsoft .NET is used for managing and working with data in a disconnected, in-memory representation. This DataSet can also 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.

:path=/static-assets/excel/content-code-examples/how-to/load-spreadsheet-load-dataset.cs
using IronXL;
using System.Data;

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

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

// Load DataSet
WorkBook.LoadWorkSheetsFromDataSet(dataSet, workBook);
Imports IronXL
Imports System.Data

' Create dataset
Private dataSet As New DataSet()

' Create workbook
Private workBook As WorkBook = WorkBook.Create()

' Load DataSet
WorkBook.LoadWorkSheetsFromDataSet(dataSet, workBook)
$vbLabelText   $csharpLabel

Frequently Asked Questions

What file formats can be loaded using this library?

IronXL supports loading XLSX, XLS, XLSM, XLTX, CSV, and TSV file formats.

How can I load a password-protected Excel workbook?

To load a password-protected Excel workbook using IronXL, use the Load method and pass the password as the second parameter.

Can this library load data directly from a byte array or stream?

Yes, IronXL can load workbook data from a byte array using the LoadFromByteArray method and from a stream using the LoadFromStream method.

What is the recommended method for loading CSV files?

While the Load method can read CSV files, it is recommended to use the LoadCSV method for optimal handling of CSV file formats with IronXL.

How does this library handle loading data from a DataSet object?

IronXL can load data from a DataSet object using the LoadWorkSheetsFromDataSet method, creating one worksheet per DataTable in the DataSet.

What is the purpose of the DataSet class in .NET?

The DataSet class in .NET is used for managing and working with data in a disconnected, in-memory representation, typically filled from database queries.

How can I get started with using this library to load spreadsheets?

To get started with IronXL, download the C# library from NuGet, prepare your file or data object, and use the Load method to load the data into a workbook object.

Chaknith related to Load DataSet
Software Engineer
Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.