Close





 
Spire.DataExport

How to Export DataTable to RTF through DataGridView

Why Export Datatable to RTF?

RTF is a Microsoft specification and certified file format used with DOC and DOCX. It is a core part of the Microsoft Office system. RTF usually used for cut and paste, including paste special and used when opening documents into Word. RTF does not cause document corruption.

 

RTF allows Workshare tremendous flexibility in successfully translating between any number of document types because of its ubiquity. Workshare products can not only maintain document fidelity, but provide portability advantages when moving around different Microsoft Word systems, or translating to other document types.

 

How to Export DataTable to RTF through DataGridView?

Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to RTF 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)
        {
            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

Step 2, Set Export into RTF

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

 

[C#]
        private void btnRun_Click(object sender, EventArgs e)
        {
            Spire.DataExport.RTF.RTFExport RTFExport = new Spire.DataExport.RTF.RTFExport();
            RTFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
            RTFExport.DataTable = this.dataGridView1.DataSource as DataTable;
            RTFExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            RTFExport.FileName = "RTF0722.rtf";
            RTFExport.SaveToFile();
        }
          


Effect Screenshot

More about Spire.DataExport

Download Spire.DataExport

Purchase Spire.DataExport

How to Export DataTable to CSV through DataGridView

When we export data out from Database we may have requirements of exporting data from Datatable to CSV because CSV is a simple file format that is widely supported. CSV (The comma-separated values) file format is a set of file formats used to store tabular data in which numbers and text are stored in plain textual form that can be read in a text editor. Lines in the text file represent rows of a table, and commas in a line separate what are fields in the table row.

 

Here we mainly discuss how to Export Datatable to CSV with Spire.DataExport for .NET.

 

Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to CSV 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.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

Step 2, Set Export into CSV

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

 

[C#]
        private void btnRUN_Click(object sender, EventArgs e)
        {
            TXTExport CSVExport = new TXTExport();
            CSVExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
            CSVExport.DataTable = this.dataGridView1.DataSource as DataTable;
            CSVExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            CSVExport.FileName = "CSV0721.csv";
            CSVExport.SaveToFile();
        }
          


Effect Screenshot

More about Spire.DataExport

Download Spire.DataExport

Purchase Spire.DataExport

How to Export DataTable to DBF through DataGridView

DBF is a format created by Ashton-Tate and can be recognized by ACT, Lipper, FoxPro, Arago, Wordtech, Xbase and other programs related with Database. Although MS Excel has been the most popular data form software application, DBF format data form files still used widely. So sometimes we may have requirements to export data from datatable to DBF. And with Spire.DataExport, we can export datatable to DBF through DataGridView effortlessly!

 

Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to DBF 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.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


Step 2, Set Export into DBF

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

 

[C#]
        private void btnRun_Click(object sender, EventArgs e)
        {
            Spire.DataExport.DBF.DBFExport DBFExport = new Spire.DataExport.DBF.DBFExport();
            DBFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
            DBFExport.DataTable = this.dataGridView1.DataSource as DataTable;
            DBFExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            DBFExport.FileName = "DBF0401.dbf";
            DBFExport.SaveToFile();
        }
          


Effect Screenshot


More about Spire.DataExport

Download Spire.DataExport

Purchase Spire.DataExport

<< Start < Prev 1 2 3 4 5 Next > End >>
Page 2 of 5