[Bug] RadGrid - Hierarchy Export To Excel (Format ExcelML)

4 posts, 0 answers
  1. SomeName
    SomeName avatar
    19 posts
    Member since:
    Jul 2011

    Posted 15 Jul 2011 Link to this post


    I have stumbled over a bug (Atleast i think its one).
    I want to expert my nested table view into excel. (excel-format: ExcelML)
    Word, CSV and Excel with format Html works fine.

    But ExcelML crashes with a null exception.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestGrid.aspx.cs" Inherits="TestGrid" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="ScriptManager" runat="server">
        <telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource"
            <ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true"
                Excel-Format="ExcelML" />
            <PagerStyle Mode="NumericPages" AlwaysVisible="true" />
            <GroupingSettings CaseSensitive="false" />
            <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true"
                DataKeyNames="ID, PARENT_ID" CommandItemDisplay="Top" AllowMultiColumnSorting="True"
                EditMode="InPlace" HierarchyLoadMode="Client" FilterExpression="PARENT_ID = 0 or PARENT_ID IS NULL">
                    <asp:Button  ID="ExportToExcelButton" runat="server"
                        CommandName="ExportToExcel" Text="Export to Excel" />
                    <asp:Button  ID="ExportToWordButton" runat="server"
                        CommandName="ExportToWord" Text="Export to Word" />
                    <asp:Button  ID="ExportToCsvButton" runat="server"
                        CommandName="ExportToCsv" Text="Export to Csv" />
                <SelfHierarchySettings ParentKeyName="PARENT_ID" KeyName="ID" MaximumDepth="0" />
                    <telerik:GridBoundColumn DataField="ID" />
                    <telerik:GridBoundColumn DataField="PARENT_ID" />
                    <telerik:GridBoundColumn DataField="NAME" />

    ASPX.CS Code Page:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using Telerik.Web.UI;
        public partial class TestGrid : System.Web.UI.Page
            protected void Page_Load(object sender, EventArgs e)
            private DataTable GetDataTable()
                DataTable returnValue = new DataTable();
                DataRow row = returnValue.NewRow();
                row["ID"] = 1;
                row["PARENT_ID"] = 0;
                row["NAME"] = "Parent A";
                row = returnValue.NewRow();
                row["ID"] = 2;
                row["PARENT_ID"] = 1;
                row["NAME"] = "Child A";
                row = returnValue.NewRow();
                row["ID"] = 3;
                row["PARENT_ID"] = 1;
                row["NAME"] = "Child B";
                row = returnValue.NewRow();
                row["ID"] = 4;
                row["PARENT_ID"] = 1;
                row["NAME"] = "Child C";
                row = returnValue.NewRow();
                row["ID"] = 5;
                row["PARENT_ID"] = 0;
                row["NAME"] = "Parent B";
                return returnValue;
            protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
                RadGrid1.DataSource = GetDataTable();

  2. Daniel
    Daniel avatar
    4935 posts

    Posted 21 Jul 2011 Link to this post


    I'm afraid RadGrid does not support exporting with self-referencing hierarchy.
    Please excuse us for any inconvenience caused.

    Best regards,
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft R3 2016 release webinar banner
  4. SomeName
    SomeName avatar
    19 posts
    Member since:
    Jul 2011

    Posted 22 Jul 2011 Link to this post

    This cant be true, as I mentioned it works fine with every export function except for Excel in the format ExcelML.
    So why should everything be supported except for ExcelML? (Exporting Excel with HTML works fine aswell)
  5. 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;



Back to Top