Przejdź do treści stopki
PORóWNAJ Z INNYMI KOMPONENTAMI
Porównanie IronXL i Spire.XLS

Porównanie IronXL i Spire XLS

Microsoft Excel to składnik pakietu Microsoft Office, który służy specjalnie do obsługi arkuszy kalkulacyjnych, mając na celu pomoc w porządkowaniu liczb i danych za pomocą formuł i funkcji.

Czy zastanawiałeś się kiedyś, jak programiści .NET radzą sobie z plikami Excel? W tym artykułe omówimy, w jaki sposób programiści obsługują pliki Excel oraz jakie narzędzia najlepiej nadają się do zapisywania, odczytywania i edytowania danych w dokumentach Excel. Dla programistów .NET konwersja plików Excel i edycja istniejących dokumentów może stanowić wyzwanie. Dzisiaj porównamy dwie popularne biblioteki .NET obsługujące dokumenty Excel: Spire XLS i bibliotekę IronXL.

2. Spire XLS

Spire.XLS for .NET to profesjonalny interfejs API Excel dla platformy .NET, który może być używany w dowolnej aplikacji .NET (C#, VB .NET, ASP.NET, .NET Core, .NET 5.0, MonoAndroid i Xamarin.iOS) do tworzenia, odczytu, zapisu, konwersji i drukowania plików Excel. Jest to obiektowy model API programu Excel, który umożliwia generowanie nowych dokumentów Excel na podstawie szablonów, edycję istniejących oraz konwersję plików Excel na platformie .NET.

Ta biblioteka jest zarządzanym zestawem .NET dla programu Excel, który nie wymaga programu Microsoft Excel. Obsługuje zarówno klasyczny format Excel 97-2003 (.xls), jak i nowoczesne formaty Excel (.xlsx, .xlsb, .xlsm). Jest to rozwiązanie szybkie i niezawodne w porównaniu z projektowaniem własnego rozwiązania do obsługi arkuszy kalkulacyjnych lub korzystaniem z Microsoft Automation.

Szyfrowanie/deszyfrowanie plików Excel, ukrywanie/wyświetlanie komórek oraz blokowanie/odblokowywanie arkuszy to tylko niektóre z funkcji zabezpieczeń dostępnych w bibliotece klas Spire.XLS.

2.1. Funkcje Spire.XLS

2.1.1. Platformy

Spire.XLS dla .NET pozwala programistom tworzyć aplikacje ASP.NET, usługi internetowe, WinForms i inne rodzaje aplikacji dla dowolnej wersji .NET Framework od 2.0 do 4.5, .NET 5.0, .NET Core, .NET Standard, MonoAndroid, Xamarin i iOS. Obsługuje zarówno systemy 32-bitowe, jak i 64-bitowe.

2.1.2. Konwersja plików

Spire.XLS umożliwia użytkownikom konwersję plików Excel do różnych formatów oraz konwersję plików w różnych formatach do plików Excel:

  • Excel do tekstu
  • Excel do obrazu
  • Plik Excel do PDF
  • Excel do HTML
  • Plik XML/CSV do Excela
  • Excel do XPS
  • Excel do SVG

2.1.3. Zawartość i funkcje

Spire.XLS dla .NET oferuje wiele funkcji do edycji i manipulacji plikami Excel, w szczególności:

  • Tworzenie i edycja skoroszytów programu Excel.
  • Zapisywanie plików Excel w strumieniach plików.
  • Wyszukiwanie i zamiana danych w skoroszytach programu Excel.
  • Sortowanie i walidacja danych.
  • Drukowanie plików.
  • Usuwanie, wstawianie lub ukrywanie wierszy i kolumn.

2.1.4. Funkcje formatowania

Spire.XLS dla .NET zapewnia pełny programowy dostęp do wszystkich elementów arkusza kalkulacyjnego i atrybutów formatowania, takich jak ustawienia czcionek, formaty liczb, wyrównanie tekstu, obiekty graficzne oraz formatowanie arkuszy, wierszy, kolumn lub zakresów komórek programu Excel.

2.1.5. Ustawienia strony

Programiści mogą konfigurować parametry ustawień strony za pomocą Spire.XLS dla .NET:

  • Ustaw obszar drukowania i tytuły wydruku lub włącz siatkę.
  • Dodaj podziały stron.
  • Utwórz lub zaktualizuj nagłówki i/lub stopki oparte na obrazach.
  • Zmiana orientacji strony, skali i rozmiaru papieru.
  • Ustaw wyśrodkowanie strony i marginesy.

3. IronXL

IronXL to biblioteka .NET, która pozwala programistom efektywnie obsługiwać pliki Excel i inne arkusze kalkulacyjne w języku C#. Office Interop nie jest wymagańy i nie ma szczególnej potrzeby instalowania pakietu Microsoft Office na platformie Core lub Azure.

Pakiet IronXL firmy Iron Software odczytuje i zapisuje pliki Excel (XLS, XLSX i CSV) w języku C# i innych językach .NET. Obsługuje .NET Core 2, Framework 4.5, Azure, Mono, Mobile i Xamarin.

IronXL pozwala nam tworzyć i eksportować dokumenty w formatach XLSX, XLS, CSV, TSV, JSON i XML. We can also export to System.Data.DataSet and System.Data.DataTable objects for SQL interoperability.

3.1. Funkcje IronXL

3.1.1. Ładowanie, odczytywanie i edycja danych

IronXL pozwala użytkownikom na manipulowanie plikami Excel w celu ładowania, odczytywania i edytowania danych z plików XLS/XLSX/CSV/TSV.

3.1.2. Zapisywanie i eksportowanie

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"]. Intuicyjnie łącz i twórz zakresy.

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

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.

Wnioski

IronXL for .NET assists developers in converting Excel to various formats, offering reading and writing of Excel in C# and other .NET languages. Obsługuje .NET Core 2, Framework 4.5, Azure, Mono, Mobile i Xamarin. IronXL jest zintegrowany z narzędziami takimi jak IronOCR, IronPDF, IronBarcode i IronWebscraper.

Spire.XLS oferuje również funkcje tworzenia, edycji i konwersji dokumentów Excel, obsługując zarówno klasyczne, jak i nowoczesne formaty Excel.

Dla porównania, IronXL oferuje więcej funkcji i konkurencyjną strukturę cenową. Więcej informacji można znaleźć na stronie internetowej IronXL, a pliki do pobrania są dostępne pod tym linkiem NuGet.

Zwróć uwagęSpire.XLS jest zastrzeżonym znakiem towarowym odpowiedniego właściciela. Ta strona nie jest powiązana z firmą Spire.XLS, nie jest przez nią promowana ani sponsorowana. Wszystkie nazwy produktów, logo i marki są własnością ich odpowiednich właścicieli. Porównania mają charakter wyłącznie informacyjny i odzwierciedlają informacje dostępne publicznie w momencie pisania.

Często Zadawane Pytania

Jak mogę przekonwertować HTML na PDF w języku C#?

Możesz użyć metody RenderHtmlAsPdf biblioteki IronPDF do konwersji ciągów HTML na pliki PDF. Możesz również konwertować pliki HTML na pliki PDF za pomocą metody RenderHtmlFileAsPdf.

Jakie są główne cechy IronXL?

IronXL umożliwia wydajne odczytywanie i zapisywanie plików Excel (XLS, XLSX, CSV) bez konieczności instalacji Office Interop lub pakietu Microsoft Office. Oferuje rozbudowane funkcje manipulacji danymi, eksportu oraz zarządzania formułami.

Jak zainstalować IronXL do obsługi plików Excel w języku C#?

IronXL można zainstalować za pomocą menedżera pakietów NuGet w Visual Studio, wiersza poleceń Visual Studio lub poprzez bezpośrednie pobranie ze stron internetowych NuGet lub IronXL.

Jak przekonwertować plik CSV do formatu Excel za pomocą IronXL?

Plik CSV można przekonwertować do formatu Excel, wczytując go do skoroszytu za pomocą IronXL, a następnie zapisując w wybranym formacie Excel.

Jakie są opcje licencyjne dla IronXL?

IronXL oferuje bezpłatną licencję dla programistów, a dodatkowe opcje licencyjne są dostępne dla dystrybucji SaaS i OEM. Wszystkie licencje obejmują 30-dniową gwarancję zwrotu pieniędzy oraz roczną pomoc techniczną i aktualizacje oprogramowania.

Jak utworzyć plik Excel za pomocą IronXL?

Aby utworzyć plik Excel za pomocą IronXL, należy użyć klasy WorkBook do utworzenia skoroszytu w formacie XLS lub XLSX, dodać arkusze, wstawić dane, zastosować style i zapisać plik w wybranej lokalizacji.

Czym różni się IronXL od Spire.XLS?

Obie biblioteki oferują możliwości tworzenia, edycji i konwersji dokumentów Excel. Biblioteka IronXL oferuje więcej funkcji, w tym integrację z dodatkowymi narzędziami, podczas gdy Spire.XLS obsługuje zarówno klasyczne, jak i nowoczesne formaty Excel. IronXL wyróżnia się konkurencyjną strukturą cenową oraz rozbudowanymi możliwościami manipulacji i konwersji plików Excel.

Czym jest Spire.XLS dla .NET?

Spire.XLS dla .NET to profesjonalny interfejs API programu Excel, który umożliwia programistom tworzenie, odczytywanie, zapisywanie, konwertowanie i drukowanie plików Excel w różnych aplikacjach .NET, obsługując wiele frameworków i formatów.

Jakie formaty Excel są obsługiwane przez Spire.XLS?

Spire.XLS obsługuje wiele formatów Excel, takich jak .xls, .xlsx, .xlsb i .xlsm, umożliwiając kompleksowe tworzenie, edycję i konwersję plików Excel bez konieczności korzystania z programu Microsoft Excel.

Czy IronXL działa bez zainstalowanego pakietu Microsoft Office?

Tak, IronXL może efektywnie odczytywać i zapisywać pliki Excel bez konieczności instalacji Office Interop lub pakietu Microsoft Office.

Jordi Bardia
Inżynier oprogramowania
Jordi jest najbardziej biegły w Pythonie, C# i C++. Kiedy nie wykorzystuje swoich umiejętności w Iron Software, programuje gry. Dzieląc odpowiedzialność za testowanie produktów, rozwój produktów i badania, Jordi wnosi ogromną wartość do ciągłej poprawy produktów. Różnorodne doświadczenia ...
Czytaj więcej

Zespol wsparcia Iron

Jestesmy online 24 godziny, 5 dni w tygodniu.
Czat
Email
Zadzwon do mnie