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

Unable to Export to Excel - RadGrid

1 Answer 275 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MikeM
Top achievements
Rank 1
MikeM asked on 03 Jun 2015, 04:37 PM
I have a Telerik RadGrid and trying to export the contents to Excel / CSV but depending upon what I do / try, get one of two errors and hoping someone could help.
Error 1:  "Unhandled exception at line 15, column 9936 in http://localhost:4940/Telerik.Web.UI.WebResource.axd?"I get this error when trying to export the contents using the following ImageButton click event.....Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal args As Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
        Try
            Dim s As String = String.Empty
            Dim exp As InvReport = New InvReport()            s = exp.GenerateInvReport()            Response.ClearContent()
            Response.ContentType = "text/comma-separated-values"
            Response.AddHeader( _
                "content-disposition", _
                "attachment; filename=" + _
                "export.csv")
            Response.Buffer = True
            Response.Write(s)
            Response.Flush()        Catch ex As Exception
            Response.Clear()
            Response.Write(ex.ToString())
            Response.Flush()
            Response.End()
        End Try        Response.End()
    End Sub
Error 2:When researching, I see that the Telerik Grid has a built in feature to allow you to export the grid's contents.  However:  this doesn't work either.  When I try the following:RadGrid1.ExportSettings.ExportOnlyData = True
RadGrid1.ExportSettings.IgnorePaging = True
RadGrid1.ExportSettings.OpenInNewWindow = True
RadGrid1.MasterTableView.ExportToCSV()
It appears the grid is "exported", but instead of opening the "Open / Save" dialog box, it just shows the contents in the same window, just one big grid without any paging.  It doesn't open a new window or anything. 

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 08 Jun 2015, 08:45 AM
Hello Mike,

This behavior is observed when you have AJAX-Enabled the grid. Note that the exporting feature works only with regular postbacks. This means, that the asynchronous postback should be canceled when performing an export.

More information on this topic is available below:

Export from ajaxified grid
Exclude controls from ajaxifying
Export RadGrid content to Excel/Word/CSV/PDF with Ajax enabled

Regards,
Kostadin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
MikeM
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or