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

ExportToExcel Problem

3 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Susan
Top achievements
Rank 1
Susan asked on 19 Aug 2011, 07:53 PM
I've got a RadGrid on a page with an Excel image above it. The onClick property of the image calls Button1_Click.

The Button1_Click code on the .cs page is:
protected void Button1_Click(object sender, System.EventArgs e)
    {
        RadGrid1.ExportSettings.FileName = "Items";
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.MasterTableView.ExportToExcel();
    }

The problem is that when clicking the image, instead of a new window opening with an Excel spreadsheet or download dialog box, the current screen is just refreshed displaying the entire contents of the grid instead of the 20 records per page. I don't know why the command would not be generating the Excel file.

Thanks for your help!

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 20 Aug 2011, 10:09 AM
Hello,

Case 1
If your grid was ajaxify than check below link and Disable Ajax on Export Time.
Grid / MS Excel/MS Word/CSV
export with ajaxify grid

Case 2
If you not used the advance data binding method for binding the data then
 RadGrid1.MasterTableView.ExportToExcel();
    RadGrid1.DataSource = "Your DataSource";
  RadGrid1.DataBind();
else
  RadGrid1.Rebind();


Let me know if any concern.

Thanks,
Jayesh Goyani
0
Daniel
Telerik team
answered on 21 Aug 2011, 12:29 PM
Hello Michael,

This happens because your RadGrid is ajaxified. I suggest that you examine the following topic for more information:
Export from Ajaxified Grid

Regards,
Daniel
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Susan
Top achievements
Rank 1
answered on 22 Aug 2011, 08:12 PM
Thanks for the help and links. I'll go through the examples and give it a shot.
Tags
Grid
Asked by
Susan
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Daniel
Telerik team
Susan
Top achievements
Rank 1
Share this question
or