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

RadGridView Exporting to Excel Problem

6 Answers 186 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chandu
Top achievements
Rank 2
Chandu asked on 26 Jul 2012, 12:58 PM

Hello All

In my silverLight application am using telerik Radgridview.
what my problem is 
i need to export only selected rows of gridview to Excel sheet.

Please help me regarding this

thanq

6 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 26 Jul 2012, 01:07 PM
Hi ,

You need to handle the ElementExporting event. Inside the handler you can check what element is being exported and in case it is not in the selected ones , just set e.Cancel = true.


All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Chandu
Top achievements
Rank 2
answered on 26 Jul 2012, 01:14 PM
Hello Pavel

 I have implemented ElementExporting as follows but am unable to get selected records.
could you give a code snippet for this anyway thanks

         private void RadGrdWorkOrders_ElementExporting(object sender, GridViewElementExportingEventArgs e)
        {
            if (e.Element == ExportElement.HeaderRow || e.Element == ExportElement.FooterRow || e.Element == ExportElement.GroupFooterRow)
            {
                e.Background = Colors.Blue; //HeaderBackgroundPicker.SelectedColor;
                e.Foreground = Colors.Orange; //HeaderForegroundPicker.SelectedColor;
                e.FontSize = 20;
                e.FontWeight = FontWeights.Bold;
            }
            else if (e.Element == ExportElement.Row)
            {
                e.Background = Colors.White;// RowBackgroundPicker.SelectedColor;
                e.Foreground = Colors.Magenta; //RowForegroundPicker.SelectedColor;
            }
            else if (e.Element == ExportElement.Cell &&
                e.Value != null && e.Value.Equals("Chocolade"))
            {
                e.FontFamily = new FontFamily("Verdana");
                e.Background = Colors.LightGray;
                e.Foreground = Colors.Blue;
            }
            else if (e.Element == ExportElement.GroupHeaderRow)
            {
                e.FontFamily = new FontFamily("Verdana");
                e.Background = Colors.LightGray;
                e.Height = 30;
            }
            else if (e.Element == ExportElement.GroupHeaderCell &&
                e.Value != null && e.Value.Equals("Chocolade"))
            {
                e.Value = "MyNewValue";
            }
            else if (e.Element == ExportElement.GroupFooterCell)
            {
                GridViewDataColumn column = e.Context as GridViewDataColumn;
                QueryableCollectionViewGroup qcvGroup = e.Value as QueryableCollectionViewGroup;


                if (column != null && qcvGroup != null && column.AggregateFunctions.Count() > 0)
                {
                    //e.Value = GetAggregates(qcvGroup, column);
                }
            }




        }


0
Kathleen
Top achievements
Rank 1
answered on 04 Nov 2013, 04:04 PM
In the latest Teleric relesae Q3 2013 we get the following warning:

Warning 2 'Telerik.Windows.Controls.GridViewElementExportingEventArgs.Foreground' is obsolete: '"This property is obsolete and it will be removed with Q1 2014. It is only supported when export format is HTML, so please, use (VisualParameters as GridViewHtmlVisualParameters).Foreground instead"' 

So while doing export to Excel, will there be any other approach recommeded?

Thanks
0
Yordanka
Telerik team
answered on 07 Nov 2013, 09:04 AM
Hello Kathleen,

We made some changes to the API with Q3 2013 version. You can check this help topic for more information. Please let us know if you have additional questions.

Regards,
Yordanka
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Senthilselvi
Top achievements
Rank 1
answered on 12 Dec 2014, 03:23 PM
The link you have provided is not working. Please let me know the option.
0
Dimitrina
Telerik team
answered on 12 Dec 2014, 03:56 PM
Hi,

You can find the correct link here: Export Events.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Chandu
Top achievements
Rank 2
Answers by
Pavel Pavlov
Telerik team
Chandu
Top achievements
Rank 2
Kathleen
Top achievements
Rank 1
Yordanka
Telerik team
Senthilselvi
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or