Skip to footer content
COMPARE TO OTHER COMPONENTS

2. Spire XLS

Spire.XLS for .NET is a professional Excel .NET API that can be used in any .NET (C#, VB .NET, ASP.NET, .NET Core, .NET 5.0, MonoAndroid, and Xamarin.iOS) application to create, read, write, convert, and print Excel files. It is an object model Excel API that allows you to generate new Excel documents from templates, edit existing ones, and convert Excel files on the .NET platform.

This library is a managed Excel .NET assembly requiring no Microsoft Excel. It supports both classic Excel 97-2003 format (.xls) and modern Excel (.xlsx, .xlsb, .xlsm) formats. It is quick and reliable compared to designing your spreadsheet manipulation solution or using Microsoft Automation.

Excel encryption/decryption, cell hide/unhide, and worksheet lock/unlock are some of the security features available in the Spire.XLS class library.

2.1. Spire.XLS Features

2.1.1. Platforms

Spire.XLS for .NET allows developers to create ASP.NET, Web Services, WinForms, and other types of applications for any .NET Framework version from 2.0 to 4.5, .NET 5.0, .NET Core, .NET Standard, MonoAndroid, Xamarin, and iOS. It supports both 32-bit and 64-bit systems.

2.1.2. File Conversion

Spire.XLS enables users to convert Excel files to different formats and convert files in different forms to Excel files:

  • Excel to Text
  • Excel to Image
  • Excel to PDF file
  • Excel to HTML
  • XML/CSV to Excel file
  • Excel to XPS
  • Excel to SVG

2.1.3. Contents and Features

Spire.XLS for .NET comes with many features to edit and manipulate Excel files, most notably:

  • Creating and editing Excel workbooks.
  • Saving Excel files to file streams.
  • Finding and replacing data in Excel workbooks.
  • Sorting and validating data.
  • Printing files.
  • Deleting, inserting, or hiding rows and columns.

2.1.4. Formatting Features

Spire.XLS for .NET provides complete programmatic access to all spreadsheet components and formatting attributes, such as font settings, number format settings, text alignment, graphic objects, and formatting worksheets, rows, columns, or a range of Excel cells.

2.1.5. Page Setup

Developers can configure Page Setup parameters using Spire.XLS for .NET:

  • Set the print area and print titles, or enable gridlines.
  • Add page breaks.
  • Create or update image-based headers and/or footers.
  • Change page direction, scale, and paper size.
  • Set page centering and margins.

3. IronXL

IronXL is a .NET library that allows developers to deal with Excel and other spreadsheet files in C# efficiently. Office Interop isn't required, and there is no particular need to install Microsoft Office on Core or Azure.

Iron Software's IronXL package reads and writes Excel (XLS, XLSX, and CSV) files in C# and other .NET languages. It supports .NET Core 2, Framework 4.5, Azure, Mono, Mobile, and Xamarin.

IronXL allows us to create and export XLSX, XLS, CSV, TSV, JSON, and XML documents. We can also export to System.Data.DataSet and System.Data.DataTable objects for SQL interoperability.

3.1. IronXL Features

3.1.1. Load, Read, and Edit Data

IronXL allows users to manipulate Excel files to load, read, and edit data from XLS/XLSX/CSV/TSV.

3.1.2. Saving and Exporting

IronXL allows users to save and export Excel files to XLS/XLSX/CSV/TSV/JSON formats.

3.1.3. System.Data Objects

IronXL works with Excel spreadsheets as System.Data.DataSet and System.Data.DataTable objects.

3.1.4. Formulas

IronXL works with Excel formulas, which are recalculated each time a sheet is edited.

3.1.5. Ranges

Easy to use WorkSheet syntax for ranges like ["A1:B10"]. Combine and create ranges intuitively.

3.1.6. Sorting

Sort ranges, columns, and rows.

3.1.7. Styling

Excel cell visual styles include font, size, background pattern, border, alignment, and number formats.

4. Creating a New Project in Visual Studio

Open Visual Studio and go to the File menu. Select "New Project", then choose a console application.

Enter the project name and select the desired path. Then, click the create button. Select the required .NET framework, as shown below:

Creating a New Project in Visual Studio

The Visual Studio project will now generate the structure for the chosen application. If a console, Windows, or web application is selected, it will open the Program.cs file where code can be entered to build and run the application.

Project Structure

Now, we can add the library and test the program.

5. Install the IronXL Library

The IronXL library can be downloaded and installed in four different ways:

  • Using the Visual Studio NuGet Package Manager
  • Using the Visual Studio Command-Line
  • Direct Download from the NuGet Webpage
  • Direct Download from the IronXL webpage

5.1 Using the Visual Studio NuGet Package Manager

Visual Studio provides the NuGet Package Manager option to install packages directly to the solution. Here is how you can open the NuGet Package Manager:

Opening the NuGet Package Manager

Search for "IronXL" in the package manager to find and install the desired package:

Searching for IronXL

Select IronXL and install the package to your solution.

5.2 Using the Visual Studio Command-Line

  • In Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Console.
  • Run the following command in the package manager console:

    Install-Package IronXL.Excel -Version 2022.3.0
    Install-Package IronXL.Excel -Version 2022.3.0
    SHELL

The package will now download to the current project and be ready for use.

Installing via Command-Line

5.3 Direct Download from the NuGet Webpage

To download the NuGet package directly:

  1. Navigate to https://www.nuget.org/packages/IronXL.Excel.
  2. Select "Download Package" from the menu on the right.
  3. Double-click the downloaded package to install it automatically.
  4. Reload the solution and start using it in the project.

5.4 Direct Download from the IronXL Webpage

Download the latest package from IronXL's webpage here. After downloading:

  1. Right-click on the project in the Solution Explorer.
  2. Select "Add Reference" and browse to the downloaded reference location.
  3. Click OK to add the reference.

6. Install the Spire.XLS

Spire.XLS offers near-identical methods for API integration:

  • Using the Visual Studio NuGet Package Manager
  • Using the Visual Studio NuGet Package Console
  • Direct Download from the Spire.XLS Website
  • Direct Download from the NuGet Website

6.1. Using the Visual Studio NuGet Package Manager

Following the process for IronXL, open the NuGet Package Manager and search for Spire.XLS:

Searching for Spire.XLS

Select the required package and install it.

6.2. Using the Visual Studio NuGet Package Console

  1. In Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Console.
  2. Run the following line in the console:

    Install-Package Spire.XLS -Version 12.3.8
    Install-Package Spire.XLS -Version 12.3.8
    SHELL

The package will be downloaded and installed in the current project.

Installing Spire.XLS via Console

6.3. Direct Download from the NuGet Website

To download Spire.XLS directly:

  1. Navigate to https://www.nuget.org/packages/Spire.XLS/.
  2. Select "Download Package" from the right-hand menu.
  3. Double-click the downloaded package to install it automatically.
  4. Reload the solution and start using it in the project.

7. Create New Excel Files

Both .NET class libraries allow creating new Excel documents easily.

7.1. Create New Excel Files Using IronXL

IronXL allows creating Excel sheets in XLS and XLSX formats. The code to create a new workbook using IronXL is as follows:

using IronXL;

class Program
{
    static void Main()
    {
        // Create a new workbook in XLS format
        WorkBook xlsWorkbook = WorkBook.Create(ExcelFileFormat.XLS);
        xlsWorkbook.Metadata.Author = "IronXL";

        // Add a blank WorkSheet
        WorkSheet xlsSheet = xlsWorkbook.CreateWorkSheet("new_sheet");

        // Add data and styles to the new worksheet
        xlsSheet["A1"].Value = "Hello World";
        xlsSheet["A2"].Style.BottomBorder.SetColor("#ff6600");
        xlsSheet["A2"].Style.BottomBorder.Type = IronXL.Styles.BorderType.Double;

        // Save the Excel file
        xlsWorkbook.SaveAs("NewExcelFile.xls");
    }
}
using IronXL;

class Program
{
    static void Main()
    {
        // Create a new workbook in XLS format
        WorkBook xlsWorkbook = WorkBook.Create(ExcelFileFormat.XLS);
        xlsWorkbook.Metadata.Author = "IronXL";

        // Add a blank WorkSheet
        WorkSheet xlsSheet = xlsWorkbook.CreateWorkSheet("new_sheet");

        // Add data and styles to the new worksheet
        xlsSheet["A1"].Value = "Hello World";
        xlsSheet["A2"].Style.BottomBorder.SetColor("#ff6600");
        xlsSheet["A2"].Style.BottomBorder.Type = IronXL.Styles.BorderType.Double;

        // Save the Excel file
        xlsWorkbook.SaveAs("NewExcelFile.xls");
    }
}
Imports IronXL



Friend Class Program

	Shared Sub Main()

		' Create a new workbook in XLS format

		Dim xlsWorkbook As WorkBook = WorkBook.Create(ExcelFileFormat.XLS)

		xlsWorkbook.Metadata.Author = "IronXL"



		' Add a blank WorkSheet

		Dim xlsSheet As WorkSheet = xlsWorkbook.CreateWorkSheet("new_sheet")



		' Add data and styles to the new worksheet

		xlsSheet("A1").Value = "Hello World"

		xlsSheet("A2").Style.BottomBorder.SetColor("#ff6600")

		xlsSheet("A2").Style.BottomBorder.Type = IronXL.Styles.BorderType.Double



		' Save the Excel file

		xlsWorkbook.SaveAs("NewExcelFile.xls")

	End Sub

End Class
$vbLabelText   $csharpLabel

7.2. Create a New Excel File Using Spire.XLS

Spire.XLS allows creating Excel files without installing MS Excel or any third-party library. Below is the sample code:

using Spire.Xls;
using System.IO;

namespace CreateExcelFiles
{
    class Program
    {
        static void Main(string[] args)
        {
            // Instantiate Workbook
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            // Set text in a specific cell
            sheet.Range["C10"].Text = "The sample demonstrates how to save an Excel workbook to a stream.";

            // Save the workbook to a stream
            FileStream fileStream = new FileStream("DEMO.xls", FileMode.Create);
            workbook.SaveToStream(fileStream);
            fileStream.Close();

            // Automatically open the new Excel file
            System.Diagnostics.Process.Start("DEMO.xls");
        }
    }
}
using Spire.Xls;
using System.IO;

namespace CreateExcelFiles
{
    class Program
    {
        static void Main(string[] args)
        {
            // Instantiate Workbook
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            // Set text in a specific cell
            sheet.Range["C10"].Text = "The sample demonstrates how to save an Excel workbook to a stream.";

            // Save the workbook to a stream
            FileStream fileStream = new FileStream("DEMO.xls", FileMode.Create);
            workbook.SaveToStream(fileStream);
            fileStream.Close();

            // Automatically open the new Excel file
            System.Diagnostics.Process.Start("DEMO.xls");
        }
    }
}
Imports Spire.Xls

Imports System.IO



Namespace CreateExcelFiles

	Friend Class Program

		Shared Sub Main(ByVal args() As String)

			' Instantiate Workbook

			Dim workbook As New Workbook()

			Dim sheet As Worksheet = workbook.Worksheets(0)



			' Set text in a specific cell

			sheet.Range("C10").Text = "The sample demonstrates how to save an Excel workbook to a stream."



			' Save the workbook to a stream

			Dim fileStream As New FileStream("DEMO.xls", FileMode.Create)

			workbook.SaveToStream(fileStream)

			fileStream.Close()



			' Automatically open the new Excel file

			System.Diagnostics.Process.Start("DEMO.xls")

		End Sub

	End Class

End Namespace
$vbLabelText   $csharpLabel

8. CSV to Excel

Converting CSV to Excel is a popular format conversion. Both IronXL and Spire.XLS provide this feature.

8.1. CSV to Excel using IronXL

IronXL enables developers to generate Excel workbooks from CSV format effortlessly. Here is how to convert a CSV file to Excel:

using IronXL;

class Program
{
    static void Main()
    {
        // Load CSV file into a workbook
        WorkBook workbook = WorkBook.LoadCSV("test.csv", fileFormat: ExcelFileFormat.XLSX, ListDelimiter: ",");
        WorkSheet ws = workbook.DefaultWorkSheet;

        // Save the workbook as an Excel file
        workbook.SaveAs("CsvToExcelConversion.xlsx");
    }
}
using IronXL;

class Program
{
    static void Main()
    {
        // Load CSV file into a workbook
        WorkBook workbook = WorkBook.LoadCSV("test.csv", fileFormat: ExcelFileFormat.XLSX, ListDelimiter: ",");
        WorkSheet ws = workbook.DefaultWorkSheet;

        // Save the workbook as an Excel file
        workbook.SaveAs("CsvToExcelConversion.xlsx");
    }
}
Imports IronXL



Friend Class Program

	Shared Sub Main()

		' Load CSV file into a workbook

		Dim workbook As WorkBook = WorkBook.LoadCSV("test.csv", fileFormat:= ExcelFileFormat.XLSX, ListDelimiter:= ",")

		Dim ws As WorkSheet = workbook.DefaultWorkSheet



		' Save the workbook as an Excel file

		workbook.SaveAs("CsvToExcelConversion.xlsx")

	End Sub

End Class
$vbLabelText   $csharpLabel

8.2. CSV to Excel using Spire.XLS

Spire.XLS handles CSV to Excel conversion efficiently. Here's how you can achieve this:

using Spire.Xls;

namespace ConvertCsvToExcel
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create an instance of Workbook class
            Workbook workbook = new Workbook();

            // Load a CSV file
            workbook.LoadFromFile(@"ExcelToCSV.csv", ",", 1, 1);

            // Get the first worksheet and used range
            Worksheet sheet = workbook.Worksheets[0];
            CellRange usedRange = sheet.AllocatedRange;
            usedRange.IgnoreErrorOptions = IgnoreErrorType.NumberAsText;

            // Autofit columns and rows
            usedRange.AutoFitColumns();
            usedRange.AutoFitRows();

            // Save the result file
            workbook.SaveToFile("CSVToExcel.xlsx", ExcelVersion.Version2013);
        }
    }
}
using Spire.Xls;

namespace ConvertCsvToExcel
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create an instance of Workbook class
            Workbook workbook = new Workbook();

            // Load a CSV file
            workbook.LoadFromFile(@"ExcelToCSV.csv", ",", 1, 1);

            // Get the first worksheet and used range
            Worksheet sheet = workbook.Worksheets[0];
            CellRange usedRange = sheet.AllocatedRange;
            usedRange.IgnoreErrorOptions = IgnoreErrorType.NumberAsText;

            // Autofit columns and rows
            usedRange.AutoFitColumns();
            usedRange.AutoFitRows();

            // Save the result file
            workbook.SaveToFile("CSVToExcel.xlsx", ExcelVersion.Version2013);
        }
    }
}
Imports Spire.Xls



Namespace ConvertCsvToExcel

	Friend Class Program

		Shared Sub Main(ByVal args() As String)

			' Create an instance of Workbook class

			Dim workbook As New Workbook()



			' Load a CSV file

			workbook.LoadFromFile("ExcelToCSV.csv", ",", 1, 1)



			' Get the first worksheet and used range

			Dim sheet As Worksheet = workbook.Worksheets(0)

			Dim usedRange As CellRange = sheet.AllocatedRange

			usedRange.IgnoreErrorOptions = IgnoreErrorType.NumberAsText



			' Autofit columns and rows

			usedRange.AutoFitColumns()

			usedRange.AutoFitRows()



			' Save the result file

			workbook.SaveToFile("CSVToExcel.xlsx", ExcelVersion.Version2013)

		End Sub

	End Class

End Namespace
$vbLabelText   $csharpLabel

9. Licensing

IronXL Licensing

IronXL provides a developer's license for free, with the Lite bundle starting at a price with no hidden fees. SaaS and OEM distribution are possible. All licenses offer a 30-day money-back guarantee, a year of software support and upgrades, and a perpetual license. For more details on IronXL pricing and licensing, visit their official licensing page.

Spire.XLS Licensing

Spire.XLS offers three licensing categories:

  • Free Version: Limited to five sheets per workbook and 200 rows per sheet. The print function is not available.
  • Standard Edition: Limited to .NET, without printing or conversion support.
  • Pro Edition: Part of the Spire.XLS Pack, supports numerous conversions like Excel to PDF, HTML, CSV, etc.

Conclusion

IronXL for .NET assists developers in converting Excel to various formats, offering reading and writing of Excel in C# and other .NET languages. It supports .NET Core 2, Framework 4.5, Azure, Mono, Mobile, and Xamarin. IronXL is integrated with tools like IronOCR, IronPDF, IronBarcode, and IronWebScraper.

Spire.XLS also provides capabilities to create, edit, and convert Excel documents, supporting both classic and modern Excel formats.

In comparison, IronXL offers more features and a competitive price structure. For more information, visit the IronXL website, and for downloads, visit this NuGet link.

Frequently Asked Questions

What is Microsoft Office Excel?

Microsoft Excel is a component of Microsoft Office that deals specifically with spreadsheets, aiming to help organize numbers and data using formulas and functions.

What is Spire.XLS for .NET?

Spire.XLS for .NET is a professional Excel .NET API that allows developers to create, read, write, convert, and print Excel files in various .NET applications. It supports both classic and modern Excel formats and offers features like encryption, decryption, and worksheet management.

What features does Spire.XLS offer?

Spire.XLS offers features such as file conversion to various formats, creating and editing workbooks, data sorting, and validation, as well as advanced formatting options like font settings, text alignment, and graphic object manipulation.

What is IronXL?

IronXL is a .NET library that allows developers to efficiently handle Excel and other spreadsheet files in C#. It supports reading and writing Excel files without needing Microsoft Office and is compatible with various .NET platforms.

How do these two .NET libraries compare?

Both libraries provide capabilities to create, edit, and convert Excel documents. The Iron Software product offers more features, including integration with additional tools, while Spire.XLS supports both classic and modern Excel formats. IronXL is noted for a competitive pricing structure.

How can I install the library for handling Excel files in C#?

The Iron Software library can be installed using the Visual Studio NuGet Package Manager, the Visual Studio Command-Line, or by direct download from the NuGet or IronXL websites.

How can I create a new Excel file using the .NET library?

To create a new Excel file using the Iron Software library, you can use the WorkBook class to create a workbook in XLS or XLSX format, add worksheets, insert data, apply styles, and save the file to a desired location.

What licensing options are available for the .NET library?

The Iron Software library offers a developer's license for free, with additional licensing options available for SaaS and OEM distribution. All licenses include a 30-day money-back guarantee and a year of software support and upgrades.

What licensing options are available for Spire.XLS?

Spire.XLS offers a free version, a Standard Edition limited to .NET without printing or conversion support, and a Pro Edition as part of the Spire.XLS Pack with support for various conversions.

How can I convert a CSV file to Excel using the .NET library?

The Iron Software library allows for easy conversion of CSV files to Excel by loading the CSV into a WorkBook and then saving it in the desired Excel format.

Regan Pun
Software Engineer
Regan graduated from the University of Reading, with a BA in Electronic Engineering. Before joining Iron Software, his previous job roles had him laser-focused on single tasks; and what he most enjoys at Iron Software is the spectrum of work he gets to undertake, whether it’s adding value to sales, technical support, product development or marketing. He enjoys understanding the way developers are using the Iron Software library, and using that knowledge to continually improve documentation and develop the products.