hi, i have used radgrid default filter for filtering items in grid using GridBoundColumn. now i want to export the dataset to excel format found by appying filter in columns. how to do it? please let me know.
sorry for my bad english.
sorry for my bad english.
7 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 18 Nov 2013, 10:50 AM
Hi Prasenjit,
I guess you want to Export to Excel the RadGrid after applying Filter. Once the RadGrid is filtered, the Grid contains the filtered data, hence this can be directly exported. Please try the following code snippet and let me know if any concern.
ASPX:
C#:
Thanks,
Princy
I guess you want to Export to Excel the RadGrid after applying Filter. Once the RadGrid is filtered, the Grid contains the filtered data, hence this can be directly exported. Please try the following code snippet and let me know if any concern.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"true"
>
<
MasterTableView
>
<
Columns
>
. . . . . . . .
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:Button
ID
=
"ButtonExport"
runat
=
"server"
Text
=
"ExportToExcel"
OnClick
=
"ButtonExport_Click"
/>
C#:
protected
void
ButtonExport_Click(
object
sender, EventArgs e)
{
RadGrid1.ExportSettings.ExportOnlyData =
true
;
RadGrid1.ExportSettings.IgnorePaging =true
;
RadGrid1.ExportSettings.FileName =
"Details"
;
RadGrid1.MasterTableView.ExportToExcel();
}
Thanks,
Princy
0

Prasenjit
Top achievements
Rank 1
answered on 18 Nov 2013, 10:56 AM
tried this.. it export to .xls format. how can i export to .xlsx format?
0

Princy
Top achievements
Rank 2
answered on 19 Nov 2013, 04:41 AM
Hi Prasenjit,
Please try setting FileExtension property as shown below:
C#:
Thanks,
Princy
Please try setting FileExtension property as shown below:
C#:
RadGrid1.ExportSettings.Excel.FileExtension =
".xlsx"
;
Thanks,
Princy
0

Prasenjit
Top achievements
Rank 1
answered on 19 Nov 2013, 06:09 AM
it shows error opening the file... please help!
0

Princy
Top achievements
Rank 2
answered on 20 Nov 2013, 04:11 AM
Hi Prasenjit,
The warning message you received is seen only with the HTML-based Excel export. There is another Excel export format (in Q2 2012 onwards) which is based on a binary XLS (BIFF) format and is supported in all versions of Microsoft Office, starting from 2003. With it, there is no longer a warning message when you open the exported file. For more information please check this documentation on Biff Export.
Thanks,
Princy
The warning message you received is seen only with the HTML-based Excel export. There is another Excel export format (in Q2 2012 onwards) which is based on a binary XLS (BIFF) format and is supported in all versions of Microsoft Office, starting from 2003. With it, there is no longer a warning message when you open the exported file. For more information please check this documentation on Biff Export.
Thanks,
Princy
0

Prasenjit
Top achievements
Rank 1
answered on 20 Nov 2013, 05:16 AM
please tell me the .aspx code and C# code to accomplish the export thing in .xlsx format.
0

Princy
Top achievements
Rank 2
answered on 21 Nov 2013, 04:03 AM
Hi Prasenjit,
Please try the sample code snippet to Export to Excel.
ASPX:
C#:
Thanks,
Princy
Please try the sample code snippet to Export to Excel.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
DataSourceID
=
"SqlDataSource1"
AllowPaging
=
"true"
AllowFilteringByColumn
=
"true"
>
<
MasterTableView
DataKeyNames
=
"OrderID"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"OrderID"
DataField
=
"OrderID"
HeaderText
=
"OrderID"
/>
<
telerik:GridBoundColumn
DataField
=
"ShipCity"
HeaderText
=
"ShipCity"
UniqueName
=
"ShipCity"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:Button
ID
=
"ButtonExport"
runat
=
"server"
Text
=
"ExportToExcel"
OnClick
=
"ButtonExport_Click"
/>
C#:
protected
void
ButtonExport_Click(
object
sender, EventArgs e)
{
RadGrid1.ExportSettings.ExportOnlyData =
true
;
RadGrid1.ExportSettings.IgnorePaging =
true
;
RadGrid1.ExportSettings.FileName =
"Details"
;
RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.Biff;
RadGrid1.ExportSettings.Excel.FileExtension =
".xlsx"
;
RadGrid1.MasterTableView.ExportToExcel();
}
Thanks,
Princy