Saltar al pie de página
COMPARAR CON OTROS COMPONENTES
Una comparación de IronXL vs Spire.XLS

Una comparación entre IronXL y Spire XLS

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

Have you ever wondered how .NET developers deal with Excel files? This article will discuss how developers handle Excel files and which tools are best suited for saving, reading, and editing data in Excel documents. .NET developers can find converting Excel files and editing existing documents challenging. Today, we will compare two popular .NET libraries that deal with Excel documents: Spire XLS and IronXL.

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

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.

Por favor notaSpire.XLS is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by Spire.XLS. All product names, logos, and brands are property of their respective owners. Comparisons are for informational purposes only and reflect publicly available information at the time of writing.

Preguntas Frecuentes

¿Cómo puedo convertir HTML a PDF en C#?

Puedes usar el método RenderHtmlAsPdf de IronPDF para convertir cadenas de HTML en PDFs. También puedes convertir archivos HTML a PDFs usando RenderHtmlFileAsPdf.

¿Cuáles son las principales características de IronXL?

IronXL soporta la lectura y escritura de archivos Excel (XLS, XLSX, CSV) de manera eficiente sin requerir la instalación de Office Interop o Microsoft Office. Ofrece manipulación de datos robusta, capacidades de exportación y gestión de fórmulas.

¿Cómo instalo IronXL para manejar archivos Excel en C#?

IronXL se puede instalar utilizando el Administrador de Paquetes NuGet de Visual Studio, la línea de comandos de Visual Studio o mediante descarga directa desde los sitios web de NuGet o IronXL.

¿Cómo convierto un archivo CSV a Excel usando IronXL?

Puede convertir un archivo CSV a Excel cargando el CSV en un WorkBook usando IronXL y luego guardándolo en el formato de Excel deseado.

¿Cuáles son las opciones de licencia para IronXL?

IronXL ofrece una licencia de desarrollador gratuita, con opciones de licencia adicionales disponibles para la distribución SaaS y OEM. Todas las licencias incluyen una garantía de devolución de dinero de 30 días y un año de soporte y actualizaciones de software.

¿Cómo creo un archivo Excel usando IronXL?

Para crear un archivo Excel usando IronXL, utilice la clase WorkBook para crear un libro de trabajo en formato XLS o XLSX, agregue hojas de trabajo, inserte datos, aplique estilos y guarde el archivo en la ubicación deseada.

¿Cómo se compara IronXL con Spire.XLS?

Ambas bibliotecas proporcionan capacidades para crear, editar y convertir documentos de Excel. IronXL ofrece más características, incluida la integración con herramientas adicionales, mientras que Spire.XLS soporta formatos de Excel clásicos y modernos. IronXL es conocido por su estructura de precios competitiva y sus amplias capacidades de manipulación y conversión de archivos de Excel.

¿Qué es Spire.XLS para .NET?

Spire.XLS para .NET es una API de Excel profesional que permite a los desarrolladores crear, leer, escribir, convertir e imprimir archivos Excel en diversas aplicaciones .NET, soportando múltiples marcos y formatos.

¿Qué formatos de Excel soporta Spire.XLS?

Spire.XLS soporta múltiples formatos de Excel como .xls, .xlsx, .xlsb y .xlsm, permitiendo la creación, edición y conversión integral de archivos Excel sin necesidad de Microsoft Excel.

¿Puede IronXL funcionar sin tener Microsoft Office instalado?

Sí, IronXL puede leer y escribir archivos Excel de manera eficiente sin requerir la instalación de Office Interop o Microsoft Office.

Jordi Bardia
Ingeniero de Software
Jordi es más competente en Python, C# y C++. Cuando no está aprovechando sus habilidades en Iron Software, está programando juegos. Compartiendo responsabilidades para pruebas de productos, desarrollo de productos e investigación, Jordi agrega un valor inmenso a la mejora continua del producto. La experiencia variada lo mantiene ...
Leer más