与其他组件比较 IronXL 和 Spire XLS 的比较 Curtis Chau 已更新:七月 28, 2025 Download IronXL NuGet 下载 DLL 下载 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article 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: 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. 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: Search for "IronXL" in the package manager to find and install the desired package: 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. 5.3 Direct Download from the NuGet Webpage To download the NuGet package directly: Navigate to https://www.nuget.org/packages/IronXL.Excel. Select "Download Package" from the menu on the right. Double-click the downloaded package to install it automatically. 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: Right-click on the project in the Solution Explorer. Select "Add Reference" and browse to the downloaded reference location. 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: Select the required package and install it. 6.2. Using the Visual Studio NuGet Package Console In Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Console. 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. 6.3. Direct Download from the NuGet Website To download Spire.XLS directly: Navigate to https://www.nuget.org/packages/Spire.XLS/. Select "Download Package" from the right-hand menu. Double-click the downloaded package to install it automatically. 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. 请注意Spire.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. 常见问题解答 如何在C#中将HTML转换为PDF? 你可以使用IronPDF的RenderHtmlAsPdf方法将HTML字符串转换为PDF。你还可以使用RenderHtmlFileAsPdf将HTML文件转换为PDF。 IronXL的主要特性是什么? IronXL高效支持读取和写入Excel(XLS, XLSX, CSV)文件,无需Office Interop或Microsoft Office安装。它提供了强大的数据操作、导出能力和公式管理。 如何在C#中安装IronXL以处理Excel文件? 可以通过Visual Studio NuGet包管理器、Visual Studio命令行或从NuGet或IronXL网站直接下载来安装IronXL。 如何使用IronXL将CSV文件转换为Excel? 您可以通过使用IronXL将CSV加载到WorkBook中,然后将其保存为所需的Excel格式来转换CSV文件。 IronXL 的许可选项有哪些? IronXL免费提供开发者许可证,并为SaaS和OEM发行提供其他许可选项。所有许可证均包括30天退款保证和一年的软件支持和升级。 如何使用IronXL创建Excel文件? 要使用IronXL创建Excel文件,使用WorkBook类在XLS或XLSX格式中创建工作簿,添加工作表,插入数据,应用样式,并将文件保存到所需位置。 IronXL与Spire.XLS比较如何? 这两种库都提供创建、编辑和转换Excel文档的功能。IronXL提供更多功能,包括与其他工具的集成,而Spire.XLS支持经典和现代Excel格式。IronXL以其具有竞争力的定价结构和广泛的Excel文件操作和转换功能而闻名。 什么是Spire.XLS for .NET? Spire.XLS for .NET是一个专业的Excel API,允许开发人员在各种.NET应用程序中创建、读取、编写、转换和打印Excel文件,支持多种框架和格式。 Spire.XLS支持哪些Excel格式? Spire.XLS支持多种Excel格式,例如.xls, .xlsx, .xlsb和.xlsm,允许全面创建、编辑和转换Excel文件,而无需Microsoft Excel。 IronXL能在没有安装Microsoft Office的情况下工作吗? 是的,IronXL能够高效读取和写入Excel文件,而无需Office Interop或Microsoft Office安装。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 相关文章 已更新六月 22, 2025 C# 开发人员使用 IronXL 的 Zip 存档教程 在本教程中,我们将探讨如何在C#中创建ZIP文件、从压缩文件中提取数据以及操作ZIP档案,使用相对路径。 阅读更多 已更新七月 28, 2025 比较三个开源 C# Excel 库 本文将探讨三个 C# 开源 Excel 库,旨在简化 .NET 环境中的 Excel 文件操作 阅读更多 已更新八月 4, 2025 EPPlus 读取 Excel 到 DataTable C#(IronXL 教程) EPPlus 是一个强大的开源库,用于在 C# 中创建和操作 Excel 文件。它提供了一个简单直观的 API,使开发人员能够以编程方式生成、读取和修改 Excel 电子表格。 阅读更多 IronXL 和 Syncfusion Excel 的比较IronXL 和 CsvWriter 的比较
已更新八月 4, 2025 EPPlus 读取 Excel 到 DataTable C#(IronXL 教程) EPPlus 是一个强大的开源库,用于在 C# 中创建和操作 Excel 文件。它提供了一个简单直观的 API,使开发人员能够以编程方式生成、读取和修改 Excel 电子表格。 阅读更多