Error In Export To Excel

5 posts, 1 answers
  1. LEON
    LEON avatar
    13 posts
    Member since:
    Nov 2018

    Posted 07 Nov 2019 Link to this post

    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 ?

     

  2. Answer
    Nadya
    Admin
    Nadya avatar
    391 posts

    Posted 08 Nov 2019 Link to this post

    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.
  3. LEON
    LEON avatar
    13 posts
    Member since:
    Nov 2018

    Posted 08 Nov 2019 Link to this post

    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.

     

  4. LEON
    LEON avatar
    13 posts
    Member since:
    Nov 2018

    Posted 08 Nov 2019 in reply to LEON Link to this post

    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.

     

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

    Process.Start("File Path including filename and extention")
  5. Nadya
    Admin
    Nadya avatar
    391 posts

    Posted 10 Nov 2019 Link to this post

    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.
Back to Top