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

Error In Export To Excel

4 Answers 386 Views
GridView
This is a migrated thread and some comments may be shown as answers.
LEON
Top achievements
Rank 1
LEON asked on 07 Nov 2019, 07:11 PM

Hi,

My issue is when I try to export the RadGridView data to excel I cant compile.

Language : VB.net

Using this code snippet

getting error on this line

Dim renderer As New Telerik.WinControls.Export.SpreadExportRenderer()

 

image attached for better understanding.

can anyone tell me what I am doing wrong?

isn't  SpreadExportRenderer member of Telerik.WinControls.Export ?

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 08 Nov 2019, 09:14 AM

Hello Leon,

The spread export functionality is located in the TelerikExport.dll assembly which must be added to your project. Could you please make sure that you have the TelerikExport.dll added to your references? Please refer to the attached picture for your reference.

I hope this helps. Should you have any other questions, I will be glad to help.

Regards,
Nadya
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
LEON
Top achievements
Rank 1
answered on 08 Nov 2019, 02:01 PM

Thanks Nadya for perfect solution.

one thing i just want to ask, since I am using MemoryStream is it possible to open the file directly? I mean saving it to windows temp file and open it from there? because currentely its not opening autometically. I can call it from windows shell but dont think that will be a ideal solution.

 

0
LEON
Top achievements
Rank 1
answered on 09 Nov 2019, 03:50 AM
[quote]LEON said:

Thanks Nadya for perfect solution.

one thing i just want to ask, since I am using MemoryStream is it possible to open the file directly? I mean saving it to windows temp file and open it from there? because currentely its not opening autometically. I can call it from windows shell but dont think that will be a ideal solution.

[/quote]

 

addedd just one line at the end of the sub, it will open the file.

Process.Start("File Path including filename and extention")
0
Nadya | Tech Support Engineer
Telerik team
answered on 11 Nov 2019, 05:47 AM

Hello Leon,

Yes, it is possible to achieve this by using MemoryStream. Please refer to the following code snippet which demonstrates a similar approach:

 Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(Me.radGridView1)
    Dim stream As Stream = New MemoryStream()
    spreadExporter.RunExport(stream, exportRenderer)
    Dim fullPath As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    Dim fileName As String = Path.Combine(fullPath, "export.xlsx")

    Using fs As FileStream = New FileStream(fileName, FileMode.OpenOrCreate)
        stream.Seek(0, SeekOrigin.Begin)
        stream.CopyTo(fs)
    End Using

    Process.Start(fileName)

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Nadya
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.
Tags
GridView
Asked by
LEON
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
LEON
Top achievements
Rank 1
Share this question
or