How to Load Existing Spreadsheets

by Chaknith Bin

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 contain in Excel file formats such as XLSX, XLS, XLSM, XLTX, CSV, and TSV as well as DataSet object can be loaded into Excel spreadsheet using IronXL.


C# NuGet Library for Excel

Install with NuGet

Install-Package IronXL.Excel
or
C# Excel DLL

Download DLL

Download DLL

Manually install into your project

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")
VB   C#

Load CSV file

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

: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")
VB   C#

Load DataSet

The DataSet class in the 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, I have created an empty dataset; however, it is more common to instantiate the DataSet from a request of a database.

: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)
VB   C#

Chaknith Bin

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.