Spire.DataExport for .NET (33)
Children categories
In this document, I will introduce you how to add Spire.DataExport controls to Toolbox for Windows Forms application.
How To
If you have already installed Spire.DataExport, you can add controls this way:
"Start" - "Programs" - "e-iceblue" - "Spire.DataExport" : Click "Add Controls into VS Toolbox".
Click "Add" to add controls.
How To
Right-click on the blank part of the Toolbo - "Add Tab" - name the new Tab "Spire Controls":
Right-click on the blank part below "Spire Controls"- "Choose Items" - ".NET Framework Components" - "Browse” to the "Bin" folde - find the file "Spire.DataExport.dll" -"Open".
Click "OK". Then you have added controls to Toolbox successfully.
The aim of the article is to introduce the procedure of exporting data into Office OpenXML in only two steps with a .net component. Spire.DataExport is a completely pure .NET component suit for exporting data into MS Excel, MS Word, HTML, Office OpenXML, PDF, MS Access, DBF, RTF, SQL Script, SYLK, DIF, CSV, MS Clipboard format. It has high performance for exporting data from Command, ListView, DataTable components, which help you to save much time and money.
Please download Spire.DataExport for .NET, add Spire.DataExport.dll as reference and set its target framework as .NET 4. Besides, many developers also check and download another C# excel component together - Spire.XLS for .NET.
Step1: Function to fill data in datatable
In this step, Spire.DataExport will help to load Data information from the datatable. After setting up the data source and SQL command, we can even preview and modify data through DataGridVew before exporting.
private void Form1_Load(object sender, EventArgs e) { oleDbConnection1.ConnectionString = txtConnectString.Text; oleDbCommand1.CommandText = txtCommandText.Text; using (OleDbDataAdapter da = new OleDbDataAdapter()) { da.SelectCommand = oleDbCommand1; da.SelectCommand.Connection = oleDbConnection1; DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; } }
Check the Screenshot below:
Step2: Export Data to Office OpenXML
The code below shows how to export data from the datatable to Office OpenXML. Spire.DataExport will create a new Office OpenXML and export data into Office OpenXML through DataGridView. It also allows you to rename the generated Office OpenXML in this step.
private void btnExportToXml_Click(object sender, EventArgs e) { Spire.DataExport.XML.XMLExport xmlExport = new Spire.DataExport.XML.XMLExport(); xmlExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable; xmlExport.DataTable = this.dataGridView1.DataSource as DataTable; xmlExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView; xmlExport.FileName = @"..\..\ToXml.xml"; xmlExport.SaveToFile(); }
Check the Screenshot below:
This article will show you a clear introduction of how to Export Data to MS Access in C# via a .NET Data Export component. Spire.DataExport for.NET is designed to help developers to perform data exporting processing tasks. With Spire.DataExport, the whole exporting process is quickly and it only needs two simple steps.
Please download Spire.DataExport for .NET and install it on your system, add Spire.DataExport.dll as reference in the downloaded Bin folder thought the below path: “…\Spire.DataExport\Bin\NET4.0\ Spire.DataExport.dll”.
Step 1: Load Data Information
In this step, Spire.DataExport helps us load data from database. Through DataGridVew, we can even preview and modify data.
private void Form1_Load(object sender, EventArgs e) { oleDbConnection1.ConnectionString = txtConnectString.Text; oleDbCommand1.CommandText = txtCommandText.Text; using (OleDbDataAdapter da = new OleDbDataAdapter()) { da.SelectCommand = oleDbCommand1; da.SelectCommand.Connection = oleDbConnection1; DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; } }
Please check the screenshot:
Step 2: Set Export into MS Access
Here we need to set it as Access format. Spire.DataExport will create a new Access and through DataGridView export data into Access file. You can rename the file as you like.
private void btnExportToAccess_Click(object sender, EventArgs e) { Spire.DataExport.Access.AccessExport accessExport = new Spire.DataExport.Access.AccessExport(); accessExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable; accessExport.DataTable = this.dataGridView1.DataSource as DataTable; accessExport.DatabaseName = @"..\..\ToMdb.mdb"; accessExport.TableName = "ExportFromDatatable"; accessExport.SaveToFile(); }
Here comes to the results: