Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 99250

How to Export Selection from Telerik RadGridView to Excel

$
0
0

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.publicvoidExecute_OpenExportView(RadGridView gridViewExport)
02.   {
03.       if(gridViewExport==null)
04.       {
05.           return;
06.       }
07. 
08.       stringextension = "xlsx";
09.       SaveFileDialog dialog = newSaveFileDialog()
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.                   newGridViewDocumentExportOptions()
33.                   {
34.                       ShowColumnFooters = true,
35.                       ShowColumnHeaders = true,
36.                       ShowGroupFooters = true,
37.                       AutoFitColumnsWidth = true,
38.                   });
39.           }
40.       }
41. 
42.   }

Viewing all articles
Browse latest Browse all 99250

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>