Hi All,
My requirement is to export the grid data into excell sheet and promt user to save this excell file on the click of a radgrid toolbar button.
I have made my set ups for this feature to work at my end like mentioned below :-
1) Added a new GridToolBar button "Export".
2) On page load i have added the code like below :-
3) Handling the button click of the grid to export the data to Excell file, used code as below :
Ex :-
The ExportGrid method is as below :
Still it does not seems to be working rather it makes the toolbar to disappear when click on the EXPORT button. :-(
Is this the right way i am going through or need to change the coding any way ?
Please help me in this regard. Thanks in advance.
My requirement is to export the grid data into excell sheet and promt user to save this excell file on the click of a radgrid toolbar button.
I have made my set ups for this feature to work at my end like mentioned below :-
1) Added a new GridToolBar button "Export".
<
telerik:RadToolBarButton
Text
=
"Excel"
ImageUrl
=
"~/Images/excel.png"
CommandName
=
"ExportToExcel"
Value
=
"Export"
/>
2) On page load i have added the code like below :-
if (!Page.IsPostBack)
{
rgMyGrid.ExportSettings.ExportOnlyData = true;
rgMyGrid.MasterTableView.UseAllDataFields = true;
rgMyGrid.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
rgMyGrid.ExportSettings.IgnorePaging = true;
rgMyGrid.ExportSettings.FileName = "CropList";
rgMyGrid.ExportSettings.OpenInNewWindow = true;
}
Ex :-
protected void rtbCommand_ButtonClick(object sender, RadToolBarEventArgs e)
{
if (e.Item.Value == "Export")
{
ExportGrid();
}
}
protected void ExportGrid()
{
rgMyGrid.ExportSettings.ExportOnlyData = true;
rgMyGrid.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
rgMyGrid.ExportSettings.IgnorePaging = true;
rgMyGrid.ExportSettings.FileName = "CropList";
rgMyGrid.ExportSettings.OpenInNewWindow = true;
rgMyGrid.MasterTableView.ExportToExcel();
}
Still it does not seems to be working rather it makes the toolbar to disappear when click on the EXPORT button. :-(
Is this the right way i am going through or need to change the coding any way ?
Please help me in this regard. Thanks in advance.