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 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.
How to Load Existing Spreadsheets
- Download the C# library to load spreadsheet
- Prepare the file or data object to be loaded into the spreadsheet
- Use the
Load
method to load the data into a workbook object - Use the
LoadWorkSheetsFromDataSet
method to load data from a DataSet object - Export the workbook as an Excel file
Install with NuGet
Install-Package IronXL.Excel
Download DLL
Manually install into your project
Install with NuGet
Install-Package IronXL.Excel
Download DLL
Manually install into your project
Start using IronPDF in your project today with a free trial.
Check out IronXL on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming Excel with C#.
Install-Package IronXL.Excel
Consider installing the IronXL DLL directly. Download and manually install it for your project or GAC form: IronXL.zip
Manually install into your project
Download DLLLoad 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")
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")
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)