Friday, 05 August 2011 03:29

Export Data from Listview to CSV

Why Export Listview to CSV?

CSV file (Comma Separated Values, sometimes also called Comma Delimited) is a specially formatted plain text file which stores spreadsheet or basic database-style information in a very simple format, with one record on each line, and each field within that record separated by a comma. It is often used to exchange data between disparate applications. CSV has become a pseudo standard throughout the industry, even among non-Microsoft platforms because it is used in Microsoft Excel.

CSV files are often used as a simple way to transfer a large volume of spreadsheet or database information between programs, without worrying about special file types. For example, transferring a home-made address book from Excel into a database program such as Filemaker Pro could be done by exporting the file as a CSV from Excel, then importing that CSV into File maker.

How to Export Listview to CSV?

Spire.DataExport for .NET presents an easy solution for exporting Listvie to CSV. Spire.DataExport is a 100% pure .NET component suit for exporting data into MS Excel, MS Word, HTML, XML, PDF, MS Access, DBF, SQL Script, SYLK, DIF, CSV ,MS Clipboard format. Quickly and easily export data from Command, ListView, DataTable components. Save you much time and money by using Spire.DataExport.

Download Spire.DataExport (or Spire.Office) with .NET framework 2.0 (or above) together and use the code below to Export Listview to CSV:

[C#]
this.txtExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
    this.txtExport1.DataFormats.CultureName = "en-us";
    this.txtExport1.DataFormats.Currency = "c";
    this.txtExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
    this.txtExport1.DataFormats.Float = "g";
    this.txtExport1.DataFormats.Integer = "g";
    this.txtExport1.DataFormats.Time = "H:mm";
    this.txtExport1.DataEncoding = Spire.DataExport.Common.EncodingType.ASCII;
    this.txtExport1.DataSource = ExportSource.ListView;
    this.txtExport1.ListView = this.ListView1
    txtExport1.ExportType = TextExportType.CSV;
    txtExport1.FileName = "sample.csv";
    txtExport1.SaveToFile();
[VB.NET]
Me.txtExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
            Me.txtExport1.DataFormats.CultureName = "en-us"
            Me.txtExport1.DataFormats.Currency = "c"
            Me.txtExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
            Me.txtExport1.DataFormats.Float = "g"
            Me.txtExport1.DataFormats.Integer = "g"
            Me.txtExport1.DataFormats.Time = "H:mm"
            Me.txtExport1.DataEncoding = Spire.DataExport.Common.EncodingType.ASCII
            Me.txtExport1.DataSource = Common.ExportSource.ListView
            Me.txtExport1.ListView = Me.ListView1
txtExport1.ExportType = TextExportType.CSV
                        txtExport1.FileName = "sample.csv"
                        txtExport1.SaveToFile()
Published in ListView Export