This article is intended to demonstrate and review the features provided by the Spire.DataExport for exporting data into multiple formats. Spire.DataExport is developed by e-icecube which are expert in developing office components and has the ability to export data into MS Word, Excel, RTF, Access, PDF, XPS, HTML, XML, Text,
CSV, DBF, SYLK, SQL Script, DIF, Clipboard etc. It's the support to export
data from Command, ListView and DataTable components faster than
Create a console application and name the solution DataExport
Spire.DataExport available in free and premium version. You can download it from the official website or
PM> Install-Package Spire.DataExport
Once you add a package to
Spire.DataExport, it will add reference of below libraries in the project.
To implement this example I have used the Northwind database (Download and restore it on your local machine).
ADO.NET we will fetch and store the product data into a
string connectionString = @"Data Source=.\SQLEXPRESS2014;Initial Catalog=NORTHWND;Integrated Security=True"; ;
using (SqlConnection con = new SqlConnection(connectionString))
using (SqlCommand command = new SqlCommand("select * from products", con))
SqlDataAdapter da = new SqlDataAdapter(command);
dt.TableName = "Export";
catch (Exception exception)
Now, Let's validate the
Spire.DataExport functionality for few document formats like excel, word, html, xml and PDF.
To Export the data we need to initialize the Spire.DataExport's
WorkSheet. Below code is useful to create and save excel file in local machine.
Spire.DataExport.XLS.CellExport cellExport = new Spire.DataExport.XLS.CellExport();
Spire.DataExport.XLS.WorkSheet worksheet1 = new Spire.DataExport.XLS.WorkSheet();
worksheet1.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
worksheet1.DataTable = dt;
worksheet1.StartDataCol = ((System.Byte)(0));
Based on implementation I concluded that
Spire.DataExport is around 53% faster than the
CloseXML. But we have one problem here, if you are using the community edition of Spire.DataExport then only allowed 40 rows to export and add extra sheet with name Evolution copy.
Let's try other formats also.
Spire.DataExport.PDF.PDFExport PDFExport = new Spire.DataExport.PDF.PDFExport();
PDFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
PDFExport.DataTable = dt;
RTFExport rtfExport = new RTFExport();
rtfExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
rtfExport.DataTable = dt;
RTFStyle rtfStyle = new RTFStyle();
rtfStyle.FontColor = Color.Blue;
rtfStyle.BackgroundColor = Color.LightGreen;
rtfExport.RTFOptions.DataStyle = rtfStyle;
rtfExport.FileName = @"..\..\SpireExport.doc";
Spire.DataExport.HTML.HTMLExport HTMLExport = new Spire.DataExport.HTML.HTMLExport();
HTMLExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
HTMLExport.DataTable = dt;
TXTExport CSVExport = new TXTExport();
CSVExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
CSVExport.DataTable = dt;
CSVExport.FileName = "SpireExport.csv";
Hope this article will help you alot
I am very impressed with the speed of exporting data into an excel sheet, which is 50% faster than other open source libraries. Spire.DataExport is very useful and efficient library to boost up data export performance. I will recommend the Spire.DataExport rather than other costly libraries available in the market.