This is a migrated thread and some comments may be shown as answers.

Export winform GridView to CSV

2 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ben
Top achievements
Rank 1
ben asked on 12 Jun 2009, 04:02 PM
I see here http://www.telerik.com/help/winforms/export-excel.html that I can export to Excel which is great, but lets say I want to export to CSV.  The corresponding ASP.NET grid control can easily do this, but I don't see a way to easily do this with the GridView control in Winforms, surely there is someway to do this?

Thanks,
Ben

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 12 Jun 2009, 04:10 PM
Hello ben,

Thank you for the question.

Please refer to the following Knowledge Base article which regards the topic of exporting RadGridView values in CSV format: Copy/Pasting rows in and between RadGridViews (CSV format).
 
If you have additional questions, feel free to contact me.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ben
Top achievements
Rank 1
answered on 12 Jun 2009, 04:32 PM
Thanks, that helped, here's what I ended up which seems to work:

 

          Dim sw As New IO.StreamWriter("C:\temp\out.csv")  
 
            'write out the column headers  
            Dim ci As Integer = 0 
            Do While ci < readingsGrid.Columns.Count 
                Dim col As GridViewColumn = readingsGrid.Columns(ci)  
                If ci > 0 Then  
                    sw.Write(",")  
                End If  
                sw.Write(col.HeaderText)  
                ci += 1  
            Loop  
            sw.Write(sw.NewLine)  
              
            'now write out the row values  
            For Each row As GridViewRowInfo In readingsGrid.Rows  
                Dim i As Integer = 0 
                Do While i < row.Cells.Count 
                    If i > 0 Then  
                        sw.Write(",")  
                    End If  
                    sw.Write(row.Cells(i).Value.ToString())  
                    i += 1  
                Loop  
                sw.Write(sw.NewLine)  
            Next row  
            sw.Close()  
 
Tags
GridView
Asked by
ben
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
ben
Top achievements
Rank 1
Share this question
or