SelfHierarchy ExportToExcel and ExportToWord Problem

6 posts, 0 answers
  1. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 14 Nov 2012 Link to this post

    I am using SelfHierarchy within my RadGrid and would like to use ExportToExcel and ExportToWord functionality. But when I export to excel or word, I see command buttons and other data are exported as-well. For example I use below code to export rows collapsed.
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
         if (e.CommandName.Contains("Export"))
             RadGrid theGrid = (RadGrid)source;
             theGrid.MasterTableView.HierarchyDefaultExpanded = false;
    Excel is OK but Word is totally messed. I see buttons and details tables are exported too.
  2. Daniel
    Daniel avatar
    4943 posts

    Posted 14 Nov 2012 Link to this post

    Hello Barbaros,

    Export of self-referencing RadGrid is not supported out-of-the-box and this is why it might behave unexpectedly in some cases. Nevertheless I prepared a simple demo showing how to remove the unwanted controls.
    We strongly recommend that you use RadTreeList control instead of RadGrid with self-referencing hierarchy.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Asutosh
    Asutosh avatar
    130 posts
    Member since:
    Sep 2013

    Posted 17 Jun 2014 in reply to Daniel Link to this post


    i am exporting heirarchy radgrid in excel

    how to export radgrid in excel without OnNeedDataSource

    i am binding datasource to radgrid on button click event 

    if i am not use OnNeedDataSource,it give me object reference is null

    my code for binding grid is 

     grd_firstchart_aco.DataSource = table;

    and code for export to excel is below
      grd_forth_aco.ExportSettings.ExportOnlyData = true;
            grd_forth_aco.ExportSettings.IgnorePaging = true;
            grd_forth_aco.ExportSettings.OpenInNewWindow = true;
            grd_forth_aco.ExportSettings.FileName = "fileName";
            grd_forth_aco.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
            grd_forth_aco.ExportSettings.HideStructureColumns = true;

            grd_forth_aco.MasterTableView.HierarchyDefaultExpanded = true;
            grd_forth_aco.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;

            grd_forth_aco.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
            grd_forth_aco.MasterTableView.DetailTables[0].HierarchyLoadMode = GridChildLoadMode.Client;


  5. Marin Bratanov
    Marin Bratanov avatar
    3595 posts

    Posted 17 Jun 2014 Link to this post

    Hello Asutosh,

    I see you have opened several threads with the very same content. I advise that you post only one per issue because this will let the person examining a case focus their efforts in one place instead of spreading information across different channels. I am closing this one, this one and this one and I suggest you continue the discussion here or open a new support ticket from your account in case your issue is urgent.


    Marin Bratanov

    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.

  6. Ashwani
    Ashwani avatar
    1 posts
    Member since:
    Jan 2015

    Posted 08 Jan Link to this post

    I am using this telerik control in my WPF application . I have one button and on click of that button i am exporting RadGridview data to excel. here is my code

     private void btnExportexecl_Click(object sender, RoutedEventArgs e)
                string extension = "xls";
                SaveFileDialog dialog = new SaveFileDialog()
                    DefaultExt = extension,
                    Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel"),
                    FilterIndex = 1
                if (dialog.ShowDialog() == true)
                    Stream stream = dialog.OpenFile();
                    new GridViewExportOptions()
                        Format = ExportFormat.ExcelML,
                        ShowColumnHeaders = true,
                        ShowColumnFooters = true,
                        ShowGroupFooters = false,
                    }, true);

    but this is exporting only one page .i have also used pagination in that case it exports the current page..i want to export all the 50 pages i tried all the above but Still struggling.. any help will be appreciated. thank you

  7. Petya
    Petya avatar
    975 posts

    Posted 11 Jan Link to this post

    Hi Ashwani,

    When the WPF RadGridView is paged, only the current page is exported. There are a couple of approaches that you can use to avoid that:
    1. Use the approach explained here and demonstrated in the ExportPagedDataExcel demo. It includes preserving the page index and size, setting them to 0 in order to export the data and then back to their values.
    2. Set the Items property of the export options to your bound collection during the time of the export
               new GridViewExportOptions()
                   Format = ExportFormat.ExcelML,
                   ShowColumnHeaders = true,
                   ShowColumnFooters = true,
                   ShowGroupFooters = false,
               }, true);

    I hope this is helpful. If you have additional questions about RadGridView for WPF please post them in the designated forum section.

    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017