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

Export to Excel is not working

1 Answer 257 Views
Button
This is a migrated thread and some comments may be shown as answers.
Elavarasan
Top achievements
Rank 1
Elavarasan asked on 02 Apr 2014, 09:25 AM
Hi,

I have used a Telerik Radgrid and I have a button to export the content from radgrid to excel. PFB the code I have used on click of the button

string alternateText = "ExcelML";
​RadGrid1.ExportSettings.Excel.Format = (GridExcelExportFormat)Enum.Parse(typeof(GridExcelExportFormat), alternateText);
RadGrid1.ExportSettings.ExportOnlyData = true;
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.ExportSettings.OpenInNewWindow = true;
RadGrid1.MasterTableView.ExportToExcel();


While Debugging, it enters the loop and exits successfully without any exception. But still, it doesn't export to an excel. Please help ASAP!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Apr 2014, 10:41 AM
Hi  Elavarasan,

I guess that you are ajaxifying the RadGrid because of that your code is not working. The exporting feature of RadGrid works with regular postbacks only. When RadGrid is ajaxified through RadAjaxManager, you would have to explicitly disable the ajax and then try exporting. .To bypass the limitation you can wire the OnRequestStart event of the ajax panel or ajax manager, determine whether the target control is ajaxified and explicitly disable its ajax mode to export with regular postback as follows.

JavaScript:
<script type="text/javascript">
    function OnRequestStart(sender, args) {
        if (args.get_eventTarget().indexOf("RadButton1") >= 0)
            args.set_enableAjax(false);
    }
</script>

Thanks,
Shinu.
Tags
Button
Asked by
Elavarasan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or