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

How to export data from RadGridView to any location

2 Answers 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 04 Jan 2019, 05:00 AM

Hello, administrator

As you know,I used the following code to export the data in the table, but how can I export the data to any location on the computer and name it instead of having to change it when the code is written

    Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(radGridView1)

    Dim exportRenderer As New SpreadExportRenderer()

    spreadExporter.RunExport("D:\exportedFile.xlsx", exportRenderer)

Looking forward to your reply

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Jan 2019, 09:36 AM
Hello, Ricardo,  
 
You can use the standard MS SaveFileDialog in order to give the opportunity the user to select the file location for the exported data. You can find below a sample code snippet:

Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
    Dim sfd As New SaveFileDialog()
    sfd.Filter = "Excel Files (*.xlsx*)|*.xlsx"
    If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
        Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(RadGridView1)
 
        Dim exportRenderer As New SpreadExportRenderer()
 
        spreadExporter.RunExport(sfd.FileName, exportRenderer)
    End If
    Process.Start(sfd.FileName)
End Sub

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ricardo
Top achievements
Rank 1
answered on 10 Jan 2019, 05:20 AM

Hello Sr.

Thank you very much for your help. My question has been well solved and your answer is of great help to me

Tags
GridView
Asked by
Ricardo
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Ricardo
Top achievements
Rank 1
Share this question
or