Silverlight GridView Export to Excel

20 posts, 0 answers
  1. Shankar
    Shankar avatar
    4 posts
    Member since:
    Aug 2008

    Posted 27 May 2010 Link to this post

    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
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 28 May 2010 Link to this post

    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.
  3. Shankar
    Shankar avatar
    4 posts
    Member since:
    Aug 2008

    Posted 03 Jun 2010 Link to this post

    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.
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 08 Jun 2010 Link to this post

    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.
  5. Adrian Pay
    Adrian Pay avatar
    28 posts
    Member since:
    Nov 2009

    Posted 12 Jul 2010 Link to this post

    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
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 12 Jul 2010 Link to this post

    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
  7. Jose
    Jose avatar
    3 posts
    Member since:
    May 2011

    Posted 18 May 2011 Link to this post

    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  
  8. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1185 posts

    Posted 20 May 2011 Link to this post

    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
  9. Chandu
    Chandu avatar
    23 posts
    Member since:
    Jul 2012

    Posted 26 Jul 2012 Link to this post

    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;
  10. Mike
    Mike avatar
    17 posts
    Member since:
    Oct 2010

    Posted 13 Nov 2012 Link to this post

    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
  11. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Nov 2012 Link to this post

    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.

  12. Mike
    Mike avatar
    17 posts
    Member since:
    Oct 2010

    Posted 14 Nov 2012 Link to this post

    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
  13. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 Nov 2012 Link to this post

    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.

  14. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 Nov 2012 Link to this post

    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.

  15. Yezdi
    Yezdi avatar
    14 posts
    Member since:
    Feb 2011

    Posted 18 May 2013 Link to this post

    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 ?
  16. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 May 2013 Link to this post

    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.

  17. Ricardo
    Ricardo avatar
    8 posts
    Member since:
    Jun 2013

    Posted 24 Jun 2014 in reply to Veselin Vasilev Link to this post

    Gracias, eh logrado exportar todo el contenido del Gridview sin importar el páginado.


    Excelente consejo
  18. Ricardo
    Ricardo avatar
    8 posts
    Member since:
    Jun 2013

    Posted 24 Jun 2014 Link to this post

    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?
  19. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Jun 2014 Link to this post

    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.
     
  20. Ricardo
    Ricardo avatar
    8 posts
    Member since:
    Jun 2013

    Posted 26 Jun 2014 in reply to Dimitrina Link to this post

    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."
Back to Top