A Comparison between IronXL and Aspose Cells

The ability to work with Excel files to generate reports and build databases has become essential for today's software applications. There are many libraries now available that allow users to do this without Microsoft Excel.

In this article, we are going to discuss and compare how to work with Microsoft Excel documents programmatically in C# .NET technologies using two of the most popular libraries, IronXL and Aspose Cells.

IronXL and Aspose Cells both provide the methods to create, edit, and read Excel documents in the .NET framework. The next question is to decide which C# Excel library is best suited to your project. This article will help you decide on the best option for your applications.

Let's look firstly at what both libraries have to offer, and then move on to the comparison itself.

The IronXL Library

IronXL is a .NET library that facilitates reading and editing Microsoft Excel documents with C#. IronXL.Excel is a standalone .NET software library for reading a wide range of spreadsheet formats. It does not require Microsoft Excel to be installed, nor does it depend on Interop.

IronXL is an intuitive C# API that allows you to read, edit and create Excel spreadsheet files in .NET with lightning-fast performance. IronXL fully supports .NET Core, .NET Framework, Xamarin, Mobile, Linux, macOS and Azure.

IronXL is a leading .NET core and .NET framework Excel spreadsheet library for C#.

You can download the software product from this link.

IronXL Feature Set

  • Load, read, and edit data — from XLS/XLSX/CSV/TSV
  • Saving and exporting — to XLS/XLSX/CSV/TSV/JSON
  • System.Data Objects — work with Excel Spreadsheets as System.Data.DataSet and System.Data.DataTable objects.
  • Formulas — works with Excel formulas. Formulas are recalculated every time a sheet is edited.
  • Ranges — easy to use WorkSheet["A1:B10"] syntax. Combine and create ranges intuitively.
  • Sorting — sort ranges, columns and rows.
  • Styling — cell visual styles, font, size, background pattern, border, alignment and number formats.

Aspose Cells

Aspose.Cells for .NET is an Excel Spreadsheet Programming API to speed up spreadsheet management and processing tasks. The API supports the building of cross-platform applications that have the ability to generate, modify, convert, render and print spreadsheets. Moreover, it does not rely on Microsoft Excel or any Microsoft Office Interop components to be installed but instead offers a robust set of APIs that deal with all Excel formats as well as CSV and SpreadsheetML formats.

By integrating the API, developers can perform basic tasks such as managing multiple worksheets, creating spreadsheet content and styles from scratch, importing data into worksheets from different data sources, adding common and complex mathematical, financial, and text formulas, manipulating charts, pictures, comments, drawing objects, and much more.

Aspose Cells Excel Spreadsheet API Features

Here are some standout features of Aspose Cells:

Rendering

  • Chart to Image
  • Worksheet to Image
  • Printing

Data Processing

  • Apply Formatting
  • Apply Formulas
  • Summarize
  • Smart Markers

Grid Suite

  • Desktop Control for WinForms
  • Web Control for ASP.NET
  • Apply Formatting
  • Apply Formulas
  • Import/Export Data

The rest of this article continues as follows:

  1. Create a Console Application
  2. IronXL C# Library Installation
  3. Aspose Cells Installation
  4. Create and Save a new Excel Workbook and Sheet
  5. Read Excel files
  6. Working with Excel Formulas
  7. Inter Convert files
  8. Licensing
  9. Conclusion

1. Create a Console Application

Use the following steps to create a Console Application:

  • Start the Visual Studio 2022 IDE.
  • Click on “Create new project”.
  • On the “Create new project” page, select C# in the language drop down list, Windows from the Platforms list, and Console from the “Project types” list.
  • Select Console App (.NET Framework) from the project templates displayed.
Create Project - Console Application
  • Click Next.
  • In the Additional Information screen, specify the Framework version you would like to use. We will use .NET Framework 4.8 in this example.
Create Project - Net Framework
  • Click Create to complete the process.

Now the project is created and we are almost ready to test the libraries. However, we still need to install and integrate them into our project. Let's install IronXL first.

2. IronXL C# Library Installation

You can download and install the IronXL library using the following methods:

  1. Using Visual Studio with NuGet packages.
  2. Download the NuGet Package directly.
  3. Manually install with the DLL.

Let’s take a closer look at each one.

2.1. Using Visual Studio with NuGet packages

Visual Studio provides the NuGet Package Manager to install NuGet packages in your projects. You can access it through the Project Menu, or by right-clicking your project in the Solution Explorer.

Select Manage NuGet Package
  • Next, from the browse tab -> search for IronXL.Excel -> Install
Search for IronXL
  • And we are done.

2.2. Download the NuGet Package Directly

This can be done by visiting the NuGet site directly and downloading the package. The steps are:

2.3. Manually Install with the DLL

Another way to download and install the IronXL C# Library is to make use of the following steps to install the IronXL NuGet package through the Developer Command Prompt.

  • Open the Developer Command Prompt — usually found in the Visual Studio folder.

Type the following command:

PM > Install-Package IronXL.Excel

  • Press Enter.
  • This will download and install the package.
  • Reload your Visual Studio project and begin using it.

2.4. Add Necessary Using Directives

  1. In Solution Explorer, right-click the Program.cs file and then click View Code.
  2. Add the following using directives to the top of the code file:
using IronXL;
using IronXL;
Imports IronXL
VB   C#

All done! IronXL is downloaded, installed, and ready to use. However, before that, we should install Microsoft.Office.Interop.Excel.

3. Aspose Cells Installation

3.1. Using Visual Studio with NuGet packages

After creating the project, access NuGet Package Manager through the Project Menu, or by right-clicking your project in the Solution Explorer.

  • Now, from the browse tab -> search for Aspose Cells -> Install

3.2. Using the NuGet Package Manager Console

Another way to download and install the Aspose Cells C# Library is to make use of the following steps to install the NuGet package through the Developer Command Prompt.

  • Open the Developer Command Prompt — usually found in the Visual Studio folder.

Type the following command:

PM> Install-Package Aspose.Cells

  • Press Enter.
  • This will download and install the package.
  • Reload your Visual Studio project and begin using it.

3.3. Direct Download

You can download any version of Aspose Cells directly from the website by clicking on this link: https://downloads.aspose.com/cells/net

Or:

download from the NuGet website: https://www.nuget.org/packages/Aspose.Cells/

3.4. Add Necessary Using Directives

  1. In Solution Explorer, right-click the Program.cs file and then click View Code.
  2. Add the following using directives to the top of the code file:
using Aspose.Cells;
using Aspose.Cells;
Imports Aspose.Cells
VB   C#

4. Create and Save a new Excel Workbook and Sheet

A workbook is an Excel file containing multiple worksheets with rows and columns. Both the libraries provide the facility to create a new Excel workbook and sheets. Let's have a look at the code step-by-step.

4.1. New Excel Workbook and Sheet using IronXL

It could not be any easier to create a new Excel Workbook using IronXL! It is just one line of code! Yes, really. Add the following code to your static void main function in the Program.cs file:

WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
Dim workbook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX)
VB   C#

Both XLS (older Excel file version) and XLSX (current and newer file version) file formats can be created with IronXL.

And, it’s even simpler to create a default Worksheet:

var worksheet = workbook.CreateWorkSheet("IronXL Features");
var worksheet = workbook.CreateWorkSheet("IronXL Features");
Dim worksheet = workbook.CreateWorkSheet("IronXL Features")
VB   C#

You can now use the worksheet variable to set cell values and do almost everything an Excel file can do.

Save Excel files:

//Save spreadsheet
workbook.SaveAs("NewExcelFile.xlsx");
//Save spreadsheet
workbook.SaveAs("NewExcelFile.xlsx");
'Save spreadsheet
workbook.SaveAs("NewExcelFile.xlsx")
VB   C#

4.2. New Excel Workbook and Sheet using Aspose.Cells

Before creating a spreadsheet and its content, a license object must be created to avoid the evaluation limitations if a licensed version was purchased. The code goes as follows:

// Create a License object
License license = new License();

// Set the license of Aspose.Cells to avoid the evaluation limitations
license.SetLicense(dataDir + "Aspose.Cells.lic");
// Create a License object
License license = new License();

// Set the license of Aspose.Cells to avoid the evaluation limitations
license.SetLicense(dataDir + "Aspose.Cells.lic");
' Create a License object
Dim license As New License()

' Set the license of Aspose.Cells to avoid the evaluation limitations
license.SetLicense(dataDir & "Aspose.Cells.lic")
VB   C#

Next, lets have a look at the code to create a workbook and worksheet. The code sample goes as follows:

// Instantiate a Workbook object that represents Excel file.
Workbook wb = new Workbook();

// When you create a new workbook, a default "Sheet1" is added to the workbook.
Worksheet sheet = wb.Worksheets[0];
// Instantiate a Workbook object that represents Excel file.
Workbook wb = new Workbook();

// When you create a new workbook, a default "Sheet1" is added to the workbook.
Worksheet sheet = wb.Worksheets[0];
' Instantiate a Workbook object that represents Excel file.
Dim wb As New Workbook()

' When you create a new workbook, a default "Sheet1" is added to the workbook.
Dim sheet As Worksheet = wb.Worksheets(0)
VB   C#

Save Excel files:

//Save spreadsheet
wb.Save("NewExcelFile.xlsx");
//Save spreadsheet
wb.Save("NewExcelFile.xlsx");
'Save spreadsheet
wb.Save("NewExcelFile.xlsx")
VB   C#

5. Read Excel Files

Both the libraries can open and read existing Excel documents. Let's have a look at the sample code.

5.1. Read Excel Files using IronXL

The IronXL WorkBook class represents an Excel sheet. To open an Excel file using C#, we use WorkBook.Load and specify the path of the Excel file (.xlsx). The following one-line code is used to open the file for reading:

//Load WorkBook
var workbook = WorkBook.Load(@"Spreadsheets\\sample.xlsx");
//Load WorkBook
var workbook = WorkBook.Load(@"Spreadsheets\\sample.xlsx");
'Load WorkBook
Dim workbook = WorkBook.Load("Spreadsheets\\sample.xlsx")
VB   C#

Each WorkBook can have multiple WorkSheet objects. These represent worksheets in the Excel document. If the workbook contains worksheets, retrieve them by name as follows:

//Open Sheet for reading
var worksheet = workbook.GetWorkSheet("sheetnamegoeshere");
//Open Sheet for reading
var worksheet = workbook.GetWorkSheet("sheetnamegoeshere");
'Open Sheet for reading
Dim worksheet = workbook.GetWorkSheet("sheetnamegoeshere")
VB   C#

Code for reading the cell values:

// Read from Ranges of cells elegantly.
foreach (var cell in worksheet["A2:A10"])
{
    Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text);
}
// Read from Ranges of cells elegantly.
foreach (var cell in worksheet["A2:A10"])
{
    Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text);
}
' Read from Ranges of cells elegantly.
For Each cell In worksheet("A2:A10")
	Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text)
Next cell
VB   C#

5.2. Read Excel Files using Aspose.Cells

Reading Excel files in Aspose cells is also a straightforward task, as it can manage multiple worksheets easily. Take a look at the code below:

// Creating a Workbook object and opening an Excel file using its file path
var workbook = new Workbook(@"Spreadsheets\\sample.xlsx");

//Adding new sheet
Worksheet sheet = workbook1.Worksheets.Add("MySheet");
// Creating a Workbook object and opening an Excel file using its file path
var workbook = new Workbook(@"Spreadsheets\\sample.xlsx");

//Adding new sheet
Worksheet sheet = workbook1.Worksheets.Add("MySheet");
' Creating a Workbook object and opening an Excel file using its file path
Dim workbook As New Workbook("Spreadsheets\\sample.xlsx")

'Adding new sheet
Dim sheet As Worksheet = workbook1.Worksheets.Add("MySheet")
VB   C#

The code for reading cell values:

//Get Cells
Cells cells = sheet.Cells;
foreach (var cell in cells)
{
    Console.WriteLine(cell.Value);
}
//Get Cells
Cells cells = sheet.Cells;
foreach (var cell in cells)
{
    Console.WriteLine(cell.Value);
}
'Get Cells
Dim cells As Cells = sheet.Cells
For Each cell In cells
	Console.WriteLine(cell.Value)
Next cell
VB   C#

6. Working with Excel Formulas

Excel formulas are one of the most important features of working with Excel files. Both the libraries have a powerful formula calculation engine. They provide the facility to work with formulas and easily apply them to cells.

6.1. Working with Excel Formulas using IronXL

After loading the workbook and worksheet, the following code sample can be used to either make changes to formulas, or be applied to specific cells. The code goes as follows:

// Set Formulas
worksheet["A1"].Formula = "Sum(B8:C12)";
worksheet["B8"].Formula = "=C9/C11";
worksheet["G30"].Formula = "Max(C3:C7)";

// Force recalculate all formula values in all sheets.  
workbook.EvaluateAll();
// Set Formulas
worksheet["A1"].Formula = "Sum(B8:C12)";
worksheet["B8"].Formula = "=C9/C11";
worksheet["G30"].Formula = "Max(C3:C7)";

// Force recalculate all formula values in all sheets.  
workbook.EvaluateAll();
' Set Formulas
worksheet("A1").Formula = "Sum(B8:C12)"
worksheet("B8").Formula = "=C9/C11"
worksheet("G30").Formula = "Max(C3:C7)"

' Force recalculate all formula values in all sheets.  
workbook.EvaluateAll()
VB   C#

You can also retrieve formulas and their values:

// Get the formula's calculated value.  e.g. "52"
string formulaValue = worksheet["G30"].Value;

//Get the formula as a string. e.g. "Max(C3:C7)"
string formulaString = worksheet["G30"].Formula;

//Save your changes with updated formulas and calculated values.
workbook.Save();
// Get the formula's calculated value.  e.g. "52"
string formulaValue = worksheet["G30"].Value;

//Get the formula as a string. e.g. "Max(C3:C7)"
string formulaString = worksheet["G30"].Formula;

//Save your changes with updated formulas and calculated values.
workbook.Save();
' Get the formula's calculated value.  e.g. "52"
Dim formulaValue As String = worksheet("G30").Value

'Get the formula as a string. e.g. "Max(C3:C7)"
Dim formulaString As String = worksheet("G30").Formula

'Save your changes with updated formulas and calculated values.
workbook.Save()
VB   C#

6.2. Working with Excel Formulas using Aspose.Cells

With Aspose.Cells it is also easy to work with formulas. Add the below code to the Excel file being read. The code goes as follows:

//Setting values
Cells cells = sheet.Cells;

//Setting formula
cells["A4"].Formula = "=SUM(A1:A3)";

// Calculating the results of formulas
workbook.CalculateFormula();
//Setting values
Cells cells = sheet.Cells;

//Setting formula
cells["A4"].Formula = "=SUM(A1:A3)";

// Calculating the results of formulas
workbook.CalculateFormula();
'Setting values
Dim cells As Cells = sheet.Cells

'Setting formula
cells("A4").Formula = "=SUM(A1:A3)"

' Calculating the results of formulas
workbook.CalculateFormula()
VB   C#

Following the above code you can set more formulas with ease.

7. Inter Convert files — (Excel, XlS, XlSX, XlSb, XlSM, XPS Data Interchange)

Both IronXL and Aspose Cells provide the facility to convert Excel xlsx files to different formats, and from different formats to Excel workbooks.

7.1. Conversion Process using IronXL

The process is pretty simple and easy. It is usually done with one line of code.

CSV to Excel formats:

WorkBook workbook = WorkBook.LoadCSV("test.csv", fileFormat: 
ExcelFileFormat.XLSX, ListDelimiter: ",");
WorkSheet ws = workbook.DefaultWorkSheet;

workbook.SaveAs("CsvToExcelConversion.xlsx");
WorkBook workbook = WorkBook.LoadCSV("test.csv", fileFormat: 
ExcelFileFormat.XLSX, ListDelimiter: ",");
WorkSheet ws = workbook.DefaultWorkSheet;

workbook.SaveAs("CsvToExcelConversion.xlsx");
Dim workbook As WorkBook = WorkBook.LoadCSV("test.csv", fileFormat:= ExcelFileFormat.XLSX, ListDelimiter:= ",")
Dim ws As WorkSheet = workbook.DefaultWorkSheet

workbook.SaveAs("CsvToExcelConversion.xlsx")
VB   C#

XLSX file to XLSM:

WorkBook workbook = WorkBook.Load("test.xlsx");

//This is how you can export workbook to .xlsm format
workbook.SaveAs("test.xlsm");
WorkBook workbook = WorkBook.Load("test.xlsx");

//This is how you can export workbook to .xlsm format
workbook.SaveAs("test.xlsm");
Dim workbook As WorkBook = WorkBook.Load("test.xlsx")

'This is how you can export workbook to .xlsm format
workbook.SaveAs("test.xlsm")
VB   C#

Excel to HTML with options:

WorkBook workbook = WorkBook.Load("test.xlsx");

var options = new HtmlExportOptions()
{
    //This is how we can make row/column numbers visible in html document
    OutputRowNumbers = true,
    OutputColumnHeaders = true,
    OutputHiddenColumns = true,

    //This is how we can make hidden rows/columns visible in html document
    OutputHiddenRows = true,
    OutputLeadingSpacesAsNonBreaking = true
};

//This is how we can export workbook to the HTML file
workbook.ExportToHtml("workbook.html",options);
WorkBook workbook = WorkBook.Load("test.xlsx");

var options = new HtmlExportOptions()
{
    //This is how we can make row/column numbers visible in html document
    OutputRowNumbers = true,
    OutputColumnHeaders = true,
    OutputHiddenColumns = true,

    //This is how we can make hidden rows/columns visible in html document
    OutputHiddenRows = true,
    OutputLeadingSpacesAsNonBreaking = true
};

//This is how we can export workbook to the HTML file
workbook.ExportToHtml("workbook.html",options);
Dim workbook As WorkBook = WorkBook.Load("test.xlsx")

Dim options = New HtmlExportOptions() With {
	.OutputRowNumbers = True,
	.OutputColumnHeaders = True,
	.OutputHiddenColumns = True,
	.OutputHiddenRows = True,
	.OutputLeadingSpacesAsNonBreaking = True
}

'This is how we can export workbook to the HTML file
workbook.ExportToHtml("workbook.html",options)
VB   C#

7.2. Conversion Process using Aspose.Cells

It is fairly simple to convert Excel xlsx files in Aspose cells as well. Take a look at the codes below:

Excel to HTML:

//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx"); 

//save file to html format
workbook.Save("out.html");
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx"); 

//save file to html format
workbook.Save("out.html");
'Load your source workbook
Dim workbook As New Workbook("Book1.xlsx")

'save file to html format
workbook.Save("out.html")
VB   C#

ODs text to Excel:

//Load your source ods text file
Workbook workbook = new Workbook("book1.ods");

//Save as xlsx file
workbook.Save("ods_out.xlsx");
//Load your source ods text file
Workbook workbook = new Workbook("book1.ods");

//Save as xlsx file
workbook.Save("ods_out.xlsx");
'Load your source ods text file
Dim workbook As New Workbook("book1.ods")

'Save as xlsx file
workbook.Save("ods_out.xlsx")
VB   C#

Excel Worksheet to SVG formats:

// Instantiate a workbook
var workbook = new Workbook();

// Populate worksheets first cell
workbook.Worksheets[0].Cells["A1"].Value = "DEMO TEXT ON SHEET1";

// Convert Worksheets
workbook.Save("ConvertWorksheetToSVG_out.svg");
// Instantiate a workbook
var workbook = new Workbook();

// Populate worksheets first cell
workbook.Worksheets[0].Cells["A1"].Value = "DEMO TEXT ON SHEET1";

// Convert Worksheets
workbook.Save("ConvertWorksheetToSVG_out.svg");
' Instantiate a workbook
Dim workbook As New Workbook()

' Populate worksheets first cell
workbook.Worksheets(0).Cells("A1").Value = "DEMO TEXT ON SHEET1"

' Convert Worksheets
workbook.Save("ConvertWorksheetToSVG_out.svg")
VB   C#

8. Licensing

IronXL is an openly commercial C# Excel library. It is free for development and can always be licensed for commercial deployment. Licenses are available for single-project use, single developers, agencies, and global corporations, as well as SaaS and OEM redistribution. All licenses include a 30-day money-back guarantee, one year of product support and updates, validity for dev/staging/production, and also a permanent license (one-time purchase). The Lite package starts from $499.

Aspose Cells is an open-source API and can be licensed for commercial use. The evaluation version of Aspose.Cells product provides full product functionality, but it is limited to the opening of 100 files in one program and has an extra worksheet with the evaluation watermark. Technical support is free and unlimited and is provided both to licensed and evaluation users. If you want to test Aspose.Cells without evaluation version limitations, request a 30-day temporary license or buy a licensed version from this link. The developer small business package starts from $1199.

9. Conclusion

In comparison, IronXL and Aspose.Cells go head-to-head when working with Excel. IronXL and Aspose.Cells both provide advanced Excel functions along with basic Excel operations. IronXL is free for development while Aspose.Cells has an evaluation period with files limited to 100 per application. Here, the advantage lies with IronXL for non-commercial use. Moreover, IronXL also provides conversion to and from the JSON format.