I am using WPF. I want to Export the selected Rows from the RadGridView to Excel. I have managed to export all the rows to Excel, but if the user makes a selection I want to export only the selected rows to Excel. Here is my code below, I just need ti implement the TODO section. Can someone help ?
01.
public
void
Execute_OpenExportView(RadGridView gridViewExport)
02.
{
03.
if
(gridViewExport==
null
)
04.
{
05.
return
;
06.
}
07.
08.
string
extension =
"xlsx"
;
09.
SaveFileDialog dialog =
new
SaveFileDialog()
10.
{
11.
DefaultExt = extension,
12.
Filter = String.Format(
"{1} files (*.{0})|*.{0}|All files(*.*)|*.*"
, extension,
"Excel"
),
13.
FilterIndex = 1,
14.
AddExtension =
true
,
15.
Title =
"Export to Excel"
,
16.
//FileName =
17.
};
18.
19.
20.
//TODO export the selected rows from RadGRidView
21.
if
(gridViewExport.SelectedItems.Count!=0)
22.
{
23.
24.
25.
}
26.
27.
if
(dialog.ShowDialog()==
true
)
28.
{
29.
using
(Stream stream = dialog.OpenFile())
30.
{
31.
gridViewExport.ExportToXlsx(stream,
32.
new
GridViewDocumentExportOptions()
33.
{
34.
ShowColumnFooters =
true
,
35.
ShowColumnHeaders =
true
,
36.
ShowGroupFooters =
true
,
37.
AutoFitColumnsWidth =
true
,
38.
});
39.
}
40.
}
41.
42.
}