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

Silverlight GridView Export to Excel

19 Answers 646 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shankar
Top achievements
Rank 1
Shankar asked on 27 May 2010, 07:31 PM
Hi,

I am using silverlight RadGridView with paging.   I want to export the gridview content to excel/csv.   I have done that task but the gridview is exporting only the current page.  I want not only the current page, but all the pages to be exported to excel.

Can any one please help me in this regard?


Thanks in advance,
Shankar

19 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 28 May 2010, 03:48 PM
Hi Shankar,

What is the source of the datapager?
Usually, you need to set the PageSize property of the data pager to 0 before calling the Export method.
After the export is done you need to set the PageSize back to its original value.

Note that if the pager is bound to DomainDataSource then you need to set the PageSize to 0 of the domain data source itself.

Hope this helps.

All the best,
Veskoni
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Shankar
Top achievements
Rank 1
answered on 03 Jun 2010, 06:45 PM
Hi Veskoni,

Its working.  Thanks a lot.

I need one more help.   I want to export all the columns in the grid to excel(or the csv format).  The grid is exporting only the visible columns, each column with the width the same width given in the gridview.  Its not exporting detailsview fields and hidden columns.  Please suggest me how to export hidden columns and detailsview fiels.

Can you please kindly help me.


Thanks in advance.
Shankar.
0
Veselin Vasilev
Telerik team
answered on 08 Jun 2010, 01:10 PM
Hello Shankar,

We have a new demo about Exporting Row Details. I believe the approach shown there will help you achieve your goals.

Best wishes,
Veskoni
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Adrian Pay
Top achievements
Rank 1
answered on 12 Jul 2010, 11:49 AM
Hi Veskoni,

I encountered the issue with performance when I tried to export the grid of 1000 rows by using Exporting function of RadGridView. It was very very slow. Note: I did the test with 1000 rows already be rendered to the RadGridView.

Please help to assist on it.

Thanks and regards,
Adrian
0
Veselin Vasilev
Telerik team
answered on 12 Jul 2010, 02:33 PM
Hi Adrian Pay,

I tested the export with 2000 rows locally and it was very fast.
Can you please open a support ticket and attach a simple project so I can debug it?

Thanks

Greetings,
Veskoni
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jose
Top achievements
Rank 1
answered on 18 May 2011, 11:09 PM
I have a RadGridView with a RadDataPager, I put the page size to 0 and then tried to export, the exporting works fine, but when try to set the page size to its original value, the RadGridView doesn't show any elements. However the ItemsCollection has all the elements, and they only appear on the RadGridView when page changing occurs. 

I'm basing my code from the GridView Exporting Paged Data example of your web site Demo.

Please Advise  
0
Ivan Ivanov
Telerik team
answered on 20 May 2011, 12:38 PM
Hello Jose,

I have just posted an answer to your inquiry in the other thread you have opened. In order to keep a fruitful and consistent dialogue, I would kindly ask you to carry out any further communication there. Thank you.

Kind regards,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chandu
Top achievements
Rank 2
answered on 26 Jul 2012, 11:35 AM
Hello Jose,

I used the following code, now i can able to export all records in my RadGridView to Excel sheet with no change in RadDataPager
lets try this........ch@ndu


                RadDataPagerRadGrdWorkOrders.PageSize = 0;
                using (Stream stream = dialog.OpenFile())
                {
                    GridViewExportOptions exportOptions = new GridViewExportOptions();
                    exportOptions.Format = format;
                    exportOptions.ShowColumnFooters = true;
                    exportOptions.ShowColumnHeaders = true;
                    exportOptions.ShowGroupFooters = true;
                    RadGrdWorkOrders.Export(stream, exportOptions);
               }
                RadDataPagerRadGrdWorkOrders.PageSize = 20;
0
Mike
Top achievements
Rank 1
answered on 13 Nov 2012, 01:29 PM
Hello Telerik Staff - Hello Forum Reader,

i got the same problem, that if i got multiple pages on my Grid, not all of the Data is Exportet - just the Data on the first Page
is getting exported.

So here's my Export Function which i call:

public static void ExportData(GridView grid)
        {
            string extension = "xls";
grid.PageSize = 0;
            ExportFormat format = ExportFormat.Html;             SaveFileDialog dialog = new SaveFileDialog();             dialog.DefaultExt = extension;             dialog.Filter = String.Format("Excel Files (*.{0})|*.{0}|Alle Files (*.*)|*.*", extension);             dialog.FilterIndex = 1;             if (dialog.ShowDialog() == true)             {                 using (Stream stream = dialog.OpenFile())                 {                     GridViewExportOptions exportOptions = new GridViewExportOptions();                     exportOptions.Format = format;                     exportOptions.ShowColumnFooters = false;                     exportOptions.ShowColumnHeaders = true;                     exportOptions.ShowGroupFooters = false;                     grid.Export(stream, exportOptions);                 }             }         }

So is set the PageSize for every time any Grid Export something.
But i still just get the first Page's Data.

What's to do to get all the Data in the Grid?

Thanks for any advice

regards
Mike
0
Dimitrina
Telerik team
answered on 13 Nov 2012, 04:17 PM
Hello,

You should set the PageSize for the DataPager, not for the GridView. From your code snippet it seems that you set it for the "grid".

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike
Top achievements
Rank 1
answered on 14 Nov 2012, 02:42 PM
Hello Didie,

thanks for your advice.
I setted the PageSitze Property of the Pager to 0 and ath the end of the Exporting i set it back to my original PageSize.
That works - so all Items getting Exported.

But i got a GridViewComboBoxColumn in my Grid. Which value is selected and i dont get the Value in my Export Excel Sheet.
Here is what it looks like:

                    <telerik:GridViewComboBoxColumn Width="Auto" Header="Mapping Organisation" Background="LightYellow"
                                                    ItemsSource="{Binding Organisations}" 
                                                    DataMemberBinding="{Binding OrganisationItem, Mode=TwoWay}"
                                                    DisplayMemberPath="OrganisationRegisterNoAndName"
                                                    SelectedValueMemberPath="OrganisationRegisterNoAndName">
                       <telerik:GridViewComboBoxColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding OrganisationItem.OrganisationRegisterNoAndName}"/>
                            </DataTemplate>
                        </telerik:GridViewComboBoxColumn.CellTemplate>
                    </telerik:GridViewComboBoxColumn>

Which property must be filled that the export is working also for the DropDownColumn?
If already tried it with this example in this post: http://www.telerik.com/community/forums/silverlight/gridview/export-doesn-t-capture-dropdown-column-values.aspx
but it didnt work for me - the value isnt exported.

thanks and regards

Mike
0
Dimitrina
Telerik team
answered on 14 Nov 2012, 04:09 PM
Hi Mike,

What do you have exported instead of the Selected value? Please note that you could subscribe for the ElementExporting event and manipulate the value to be exported if needed.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dimitrina
Telerik team
answered on 14 Nov 2012, 04:19 PM
Hi,

You can as well check this help article showing how to export values placed inside a TextBlock. The article is for custom Header but the same approach can be applied for the defined CellTemplate.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Yezdi
Top achievements
Rank 1
answered on 19 May 2013, 02:34 AM
Hi,
I am using Silverlight RadGridView with VirtualQueryableCollectionView for virtualized data loading while scrolling. I want to use Export features but as the current Export functionality will only export the data which is already loaded in the visible area of the grid, how should i proceed ?
0
Dimitrina
Telerik team
answered on 20 May 2013, 08:03 AM
Hello,

If you want to be able to export all items you must ensure that they are loaded. Thus, I am afraid that you cannot achieve the desired behavior when using the Data Virtualization as it items are loaded when requested to be shown into view. I can suggest you to use a QueryableCollectionView or other collection that has all the items available.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ricardo
Top achievements
Rank 1
answered on 24 Jun 2014, 03:45 PM
Gracias, eh logrado exportar todo el contenido del Gridview sin importar el páginado.


Excelente consejo
0
Ricardo
Top achievements
Rank 1
answered on 24 Jun 2014, 07:41 PM
Hola,
como puedo quitar el mensaje de advertencia al intentar abrir el documento de excel que se genero.

Warning message when opening the excel file:

The file you are trying to open, 'Filename.xls', is in a different format than specified by the file extension. Verify that the file is not
corrupted and is from a trusted source before opening this file. Do you want to open the file now?
0
Dimitrina
Telerik team
answered on 25 Jun 2014, 09:09 AM
Hi,

RadGridView can export with ExportFormat.HTML and ExportFormat.ExcelML - in both cases not native for Excel 2010. In case of HTML export you will get such warning and this cannot be avoided, however if you export to ExcelML with XML extension you will not get it. 

Please check this help article for a further information:
Warning message when opening the excel file.

You can also export data with RadSpreadProcessing. The model is completely independent from UI. You can check Export with RadSpreadProcessing as an example on how to do so.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Ricardo
Top achievements
Rank 1
answered on 26 Jun 2014, 03:18 PM
Hola,
Eh logrado exportar los datos con RadSpreadProcessing pero cuando se intenta exportar muchos registros el dialog.ShowDialog() == true manda una excepción "Los cuadros de diálogos deben ser iniciados por el usuario."
Tags
GridView
Asked by
Shankar
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Shankar
Top achievements
Rank 1
Adrian Pay
Top achievements
Rank 1
Jose
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Chandu
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Dimitrina
Telerik team
Yezdi
Top achievements
Rank 1
Ricardo
Top achievements
Rank 1
Share this question
or