Spire.DataExport

Spire.DataExport supports exporting data from DataTable into HTML. HTML (HyperText Markup Language) is a language for describing web pages. HTML documents are also called web pages which contain HTML tags and plain text. Use Spire.DataExport exporting DataTable to HTML to share your data on internet.

Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to HTML exporting process.

Step 1: Load Data Information

Before exporting data from DataTable, we should load data information from data source. And select which information we need export. Through DataGridVew, we even can preview and modify data information. So, in this step, our job is to prepare data which are about to be exported out.

[C#]
	
        private void btnLoad_Click(object sender, EventArgs e)
        {
            using (OleDbConnection oleDbConnection = new OleDbConnection())
            {
                oleDbConnection.ConnectionString = this.tbCS.Text;
                System.Data.OleDb.OleDbCommand oleDbCommand = new OleDbCommand();
                oleDbCommand.CommandText = this.tbCT.Text;
                oleDbCommand.Connection = oleDbConnection;
                using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
                {
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
            }
        }
   

Effect Screenshot

DataTable to HTML

Step 2: Set Export into HTML

Spire.DataExport allows user to export data into most popular file formats including MS Excel, MS Word, HTML, PDF, XML, CSV, DBF, DIF, etc. Here we need set it as HTML format. Spire.DataExport will create a new HTML file and through DataGridView export data into HTML file. You also can rename the file as you like.

[C#]
        private void btnRun_Click(object sender, EventArgs e)
        {
            Spire.DataExport.HTML.HTMLExport HTMLExport = new Spire.DataExport.HTML.HTMLExport();
            HTMLExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
            HTMLExport.DataTable = this.dataGridView1.DataSource as DataTable;
            HTMLExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            HTMLExport.SaveToFile("20110223.html");
        }  

Effect Screenshot

DataTable to HTML

Export DataTable to Excel can be very easy through Spire.DataExport (or Spire.Office). Furthermore, Spire.DataExport enables user to Export data to Excel through DataGridView. Through DataGridView users can preview and modify data information before exporting.

Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to Excel exporting process.

Step 1: Load Data Information

In this step, Spire.DataExport will help you load Data information from your datatable. After you put in your data source and SQL command, you can preview and modify data information in DataGridView area.

[C#]
	
        private void btnLoad_Click(object sender, EventArgs e)
        {
            using(OleDbConnection oleDbConnection = new OleDbConnection())
            {
                oleDbConnection.ConnectionString = this.textBox1.Text;
                OleDbCommand oleDbCommand = new OleDbCommand();
                oleDbCommand.CommandText = this.textBox2.Text;
                oleDbCommand.Connection = oleDbConnection;
                using(OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
                {
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
            }
        } 

   

Effect Screenshot

DataTable to Excel

Step 2: Set Export into Excel

Spire.DataExport allows user to export data into most popular file formats including MS Excel, MS Word, HTML, PDF, XML, CSV, DBF, DIF, etc. Now, in this step you should give an order to Export Data into Excel file format. Spire.DataExport will create a new MS Excel Worksheet for storing Data which exported out. You can rename the excel file in this step either.

[C#]
        private void btnRun_Click(object sender, EventArgs e)
        {
            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 = this.dataGridView1.DataSource as DataTable;
            worksheet1.StartDataCol = ((System.Byte)(0));
            cellExport.Sheets.Add(worksheet1);
            cellExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView; 
            cellExport.SaveToFile("20110223.xls");
        }
       

Effect Screenshot

DataTable to Excel

Spire.DataExport, a professional .NET DataExport component, enables users to export data from database, datatable and other datasoure to MS Excel, MS Word, PDF, MS Access, DBF, SQL Script, SYLK, DIF, CSV and MS Clipboard without MS Office, Adobe Acrobat and other third-party installed on system. With Spire.DataExport, developer can create any WinForm and Web applications to export data.

Spire.DataExport is fantastic on formatting when exporting, especially for Excel. Users can format data, import formula, insert objects (image, hyperlinks etc.) and create chart when export a large amount of data to multiple worksheets. The following sections will present how to quickly export data in details.

Page 3 of 5