Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
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.
Have you ever wondered how .NET developers deal with Excel files? This article will discuss how developers deal with Excel files and which tools are best suited to the job of saving, reading and editing data in Excel documents. .NET developers find it very difficult to convert Excel files and edit existing Excel documents. Today, we will compare two of the popular .NET libraries that deal with Excel documents. These are:
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. Spire.XLS for .NET is an object model Excel API that allows you to generate new Excel documents from templates, edit existing Excel documents, and convert Excel files on the .NET platform.
This professional .NET Excel API is a managed Excel .NET assembly requiring Microsoft Excel. Spire.XLS for .NET supports the classic Excel 97-2003 format (.xls) and the modern Excel (.xlsx,.xlsb,.xlsm) formats. It is quick and reliable compared to designing your own spreadsheet manipulation solution or using Microsoft Automation.
Excel encryption/decryption, cell hide/unhide, as well as worksheet lock/unlock are just a few of the security capabilities available in Spire.XLS for .NET class library.
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.
Spire.XLS enables users to both convert Excel files to different formats and files in different formats to Excel files.
Spire.XLS for .NET comes with a long list of features to edit and manipulate Excel files, the most important of which are given below:
Spire.XLS for .NET gives complete programmatic access to all spreadsheet components and formatting attributes, such as font settings, number format settings, text alignment settings, graphic objects, as well as formatting worksheets, rows, columns, or a range of Excel cells, among many others.
Developers/programmers may configure Page Setup parameters using Spire.XLS for .NET.
IronXL is a .NET library allowing developers to deal with Excel and other spreadsheet files in C# quickly and straightforwardly. Office Interop isn't required. There are no particular requirements or the need to install Microsoft Office on Core or Azure.
Iron Software's IronXL software package reads and writes Excel (XLS, XLSX, and CSV) files simply in C# and other .NET languages. .NET Core 2, Framework 4.5, Azure, Mono, Mobile, and Xamarin are all supported by IronXL.
IronXL is a leading .NET Core and .NET Excel spreadsheet library for C# and VB. NET. The IronXL library is used 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 interoperability with SQL.
IronXL allows users to manipulate Excel files in order to load, read and edit data from XLS/XLSX/CSV/TSV.
IronXL allows users to save and export Excel files to XLS/XLSX/CSV/TSV/JSON formats.
IronXL works with Excel spreadsheets as System.Data.DataSet and System.Data.DataTable objects.
IronXL works with Excel formulas. Formulas are recalculated every time a sheet it edited.
Easy to use WorkSheet ["A1:B10"] syntax. Combine and create ranges intuitively.
Sort ranges, columns, and rows.
Excel cell visual styles font, size, background pattern, border, alignment and number formats.
Open the Visual Studio software and go to the File menu. Select "new project" and then select console application.
Enter the project name and select the path in the appropriate text box. Then, click the create button. Select the required .NET framework, as in the screenshot below:
The Visual Studio project will now generate the structure for the selected application, and if you have selected the console, Windows, and web application, it will open the program.cs file where you can enter the code and build/run the application.
Now we can add the library and test the program.
The IronXL library can be downloaded and installed in four different ways. These are:
The Visual Studio software provides the NuGet Package Manager option to install the package directly to the solution. The below screenshot shows how to open the NuGet Package Manager.
It provides the search box to show the list of available package libraries from the NuGet website. In the package manager, we need to search for the keyword "IronXL", as in the below screenshot:
From the above image, we can see that we will get the list of relevant packages. We need to select the IronXL option and install the package to our solution.
The package will now download/install to the current project and be ready to use.
The third way is to download the NuGet package directly from the webpage.
Click the link here to download the latest package directly from the webpage. After the download, follow the steps below to add the package to the project.
The Spire.XLS team offers nearly all the same methods to integrate the API. These are:
As explained previously for IronPDF, the steps are the same for opening the NuGet Package Manager.
After opening the Package Manager, simply write Spire.XLS in the search bar.
As the above image shows, there are three results for Spire.XLS. Select the required option.
In the Visual Studio menu, go to Tools-> NuGet Package manager -> Package manager Console. Enter the following line in the package manager console tab: Install-Package Spire.XLS -Version 12.3.8. The package will now download/install to the current project and be ready to use.
The third way is to download the NuGet package directly from the webpage.
Both .NET class libraries allow users to create new Excel documents with simple code.
The IronXL library can be used to create Excel Sheets in XLS and XLSX formats.
Using the IronXL API it is intuitive to populate your workbook and save it all on the .NET platform.
IronXL also fully supports ASP.NET, MVC, Windows, MacOS, Linux, iOS, Android and Windows Mobile application development.
The following code shows how to create a new workbook using IronXL.
using IronXL;
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;
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
Private 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")
Without installing MS Excel or any third-party library, Spire.XLS for .NET allows you to produce Excel files in the formats of Excel (.xls) 97-2003, Excel (.xlsx) 2007, and Excel (.xlsx) 2010. This Excel API allows you to create Excel files, but it also allows you to read, edit, and modify Excel files in .NET applications with ease.
Below is the sample code for you:
using Spire.Xls;
using System.IO;
namespace CreateExcelFiles
{
class Program
{
static void Main(string [] args)
{
Workbook DEMO= new Workbook();
Worksheet sheet = DEMO.Worksheets [0];
sheet.Range ["C10"].Text = "The sample demonstrates how to save an Excel workbook to stream.";
FileStream file_stream = new FileStream("DEMO.xls", FileMode.Create);
wbToStream.SaveToStream(file_stream);
file_stream.Close();
System.Diagnostics.Process.Start("DEMO.xls");
}
}
}
using Spire.Xls;
using System.IO;
namespace CreateExcelFiles
{
class Program
{
static void Main(string [] args)
{
Workbook DEMO= new Workbook();
Worksheet sheet = DEMO.Worksheets [0];
sheet.Range ["C10"].Text = "The sample demonstrates how to save an Excel workbook to stream.";
FileStream file_stream = new FileStream("DEMO.xls", FileMode.Create);
wbToStream.SaveToStream(file_stream);
file_stream.Close();
System.Diagnostics.Process.Start("DEMO.xls");
}
}
}
Imports Spire.Xls
Imports System.IO
Namespace CreateExcelFiles
Friend Class Program
Shared Sub Main(ByVal args() As String)
Dim DEMO As New Workbook()
Dim sheet As Worksheet = DEMO.Worksheets (0)
sheet.Range ("C10").Text = "The sample demonstrates how to save an Excel workbook to stream."
Dim file_stream As New FileStream("DEMO.xls", FileMode.Create)
wbToStream.SaveToStream(file_stream)
file_stream.Close()
System.Diagnostics.Process.Start("DEMO.xls")
End Sub
End Class
End Namespace
CSV to Excel is one of the most popular format conversions for Excel users. IronXL and Spire.XLS both provide this conversion feature.
IronXL enables developers to generate Excel workbooks from CSV format.
Use IronXL to quickly convert comma-separated values text files (.csv) into Excel worksheets.
It shows how to import CSV and "tab-separated values" TSV data into Excel Worksheets in C#.
Below is the code example to convert CSV to Excel programming.
using IronXL;
WorkBook workbook = WorkBook.LoadCSV("test.csv", fileFormat: ExcelFileFormat.XLSX, ListDelimiter: ",");
WorkSheet ws = workbook.DefaultWorkSheet;
workbook.SaveAs("CsvToExcelConversion.xlsx");
using IronXL;
WorkBook workbook = WorkBook.LoadCSV("test.csv", fileFormat: ExcelFileFormat.XLSX, ListDelimiter: ",");
WorkSheet ws = workbook.DefaultWorkSheet;
workbook.SaveAs("CsvToExcelConversion.xlsx");
Imports IronXL
Private workbook As WorkBook = WorkBook.LoadCSV("test.csv", fileFormat:= ExcelFileFormat.XLSX, ListDelimiter:= ",")
Private ws As WorkSheet = workbook.DefaultWorkSheet
workbook.SaveAs("CsvToExcelConversion.xlsx")
A CSV file is a plain text file with data separated by commas. They are commonly used to export data from one application to another. Conversions between CSV and Excel may be necessary for some circumstances. This post will show you how to use Spire.XLS for the .NET library to implement this method in C# programmatically.
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
Worksheet sheet = workbook.Worksheets [0];
//Access the used range in the worksheet
CellRange usedRange = sheet.AllocatedRange;
//Ignore errors when saving numbers in the range as text
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
Worksheet sheet = workbook.Worksheets [0];
//Access the used range in the worksheet
CellRange usedRange = sheet.AllocatedRange;
//Ignore errors when saving numbers in the range as text
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
Dim sheet As Worksheet = workbook.Worksheets (0)
'Access the used range in the worksheet
Dim usedRange As CellRange = sheet.AllocatedRange
'Ignore errors when saving numbers in the range as text
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
IronXL is a library that provides a developer's license for free. IronXL also has a distinct pricing structure: the Lite bundle starts at $749 with no hidden fees. The redistribution of SaaS and OEM products is also possible. All licenses have a 30-day money-back guarantee, a year of software support and upgrades, dev/staging/production validity, and a perpetual license (one-time purchase). To see IronXL's entire price structure and license, go here.
Spire.XLS provides flexible options for licensing the Spire.XLS .NET component. It provides three different categories of licensing.
There are only five sheets per workbook and 200 rows per sheet in the free version. The print function isn't available. When converting Excel files to other formats, such as PDF/XPS, you can only receive the first three pages and convert the first three sheets to images.
The Spire.XLS for .NET Standard Edition is limited to .NET and does not support printing or conversion.
Standard Edition is not compatible with .NET Core.
The Spire.XLS Pro Edition is included in the Spire.XLS Pack and supports converting files from Excel to PDF, HTML, Excel to CSV, Excel to text, Excel to images, and Excel to XML (the Excel can be either .XLS or.XLSX).
IronXL for .NET enables developers to convert Excel to different formats such as XLS files to XLSX file stream. IronXL for .NET offers reading and writing Excel (XLS, XLSX, and CSV) files in C# and other .NET languages. .NET Core 2, Framework 4.5, Azure, Mono, Mobile, and Xamarin are all supported by IronXL. The IronXL library is used to create and export XLSX, XLS, CSV, TSV, JSON and XML documents. On top of all that, Iron Software offers all its five tools for the price of just two. The tools are as follows:
Spire.XLS for .NET allows you to create new Excel documents from templates, edit existing Excel documents, and convert Excel files with the Excel API for the .NET platform. Spire.XLS for .NET supports both the traditional Excel 97-2003 (.xls) and the current Excel (.xlsx,.xlsb,.xlsm) formats. It is quick and dependable compared to creating your own spreadsheet manipulation solution or using Microsoft Automation.
After briefly comparing both .NET tools, we now know that IronXL provides more features than Spire.XLS. The IronXL price structure is relatively low compared to that of Spire.XLS. The IronXL unlimited package for unlimited developers, locations and unlimited projects with SaaS and OME coverage and five years of support and updates retails for just $5397.00. On the other hand, the Spire.XLS Pro Edition with Site OEM subscription does not offer unlimited developers — just 50 developers. It provides unlimited locations but only one year of support and updates at the price of $15,687.00.
For more information please visit IronXL, and for downloads please visit this link.
9 .NET API products for your office documents