Hierarchical Grid Excel Export

14 posts, 0 answers
  1. ESM Dev
    ESM Dev avatar
    15 posts
    Member since:
    Apr 2009

    Posted 03 Jul 2009 Link to this post

    I am working on hierarchical grid where I am having 1 details tables each one resides inside other. It is like drilldown feature. My next task is to export complete data on the grid to Excel.

    I dont want to show ExpandCollapse button inside Excel. Please suggest how to overcome these problems.

    Thanks
    Venkat
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 06 Jul 2009 Link to this post

    Hi,

    Attached to this message is a simple runnable application that demonstrates the needed approach. Please give it a try and see if it works for you or if I am leaving something out.

    Best wishes,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ESM Dev
    ESM Dev avatar
    15 posts
    Member since:
    Apr 2009

    Posted 07 Jul 2009 Link to this post

    Hi,

    Tried with the given attachment, but still not dropping the expand/collapse column. Have a look at RadGrid am using.

     

    <telerik:RadGrid ID="RadGridParent" runat="server" Width="100%" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" PageSize="5" GridLines="None" OnNeedDataSource="RadGridParent_NeedDataSource" OnItemCommand="RadGridParent_ItemCommand" Visible="False">      

    <MasterTableView DataKeyNames="I3_Rowid" AllowMultiColumnSorting="True">
    <NestedViewTemplate>
    <asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap" Visible="false">
    <asp:Button ID="btnExpChildData" Text="Export to Excel" SkinID="Button" runat="server" Visible="false" OnClick="Export_Click" CommandName="Child" /> <br /> <br />
    <telerik:RadGrid ID="RadGridChild" runat="server" Width="100%" GridLines="None" PageSize="5" AllowPaging="True" OnNeedDataSource="RadGridChild_NeedDataSource" ShowStatusBar="True" AllowSorting="True">  

    </telerik:RadGrid>
    </asp:Panel>
    </NestedViewTemplate>
    <Columns> <telerik:GridBoundColumn SortExpression="I3_RowID" HeaderText="I3_RowID" HeaderButtonType="TextButton"  

    DataField="I3_RowID" UniqueName="I3_RowID"> </telerik:GridBoundColumn>
    <telerik:GridBoundColumn SortExpression="ESM_Client_I3_RowID" HeaderText="ESM_Client_I3_RowID" HeaderButtonType="TextButton" DataField="ESM_Client_I3_RowID" UniqueName="ESM_Client_I3_RowID"> </telerik:GridBoundColumn>
    <telerik:GridBoundColumn SortExpression="CampaignID" HeaderText="CampaignID" HeaderButtonType="TextButton" DataField="CampaignID" UniqueName="CampaignID">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn SortExpression="CampaignName" HeaderText="CampaignName" HeaderButtonType="TextButton" DataField="CampaignName" UniqueName="CampaignName">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn SortExpression="ScriptID" HeaderText="ScriptID" HeaderButtonType="TextButton"   DataField="ScriptID" UniqueName="ScriptID">   </telerik:GridBoundColumn   <telerik:GridBoundColumn SortExpression="ScriptName" HeaderText="ScriptName" HeaderButtonType="TextButton"   DataField="ScriptName" UniqueName="ScriptName"> </telerik:GridBoundColumn   <telerik:GridBoundColumn SortExpression="LeadInquiryDate" DataFormatString="{0:MM/dd/yyyy}" HeaderButtonType="TextButton" HeaderText="LeadInquiryDate" DataField="LeadInquiryDate" UniqueName="LeadInquiryDate">    </telerik:GridBoundColumn   <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="FirstName" HeaderButtonType="TextButton"   DataField="FirstName" UniqueName="FirstName">    </telerik:GridBoundColumn   

    <telerik:GridBoundColumn SortExpression="LastName" HeaderText="LastName" HeaderButtonType="TextButton"   DataField="LastName" UniqueName="LastName">  </telerik:GridBoundColumn
    <telerik:GridBoundColumn SortExpression="DateAdded" DataFormatString="{0:MM/dd/yyyy}" HeaderButtonType="TextButton" HeaderText="DateAdded" DataField="DateAdded" UniqueName="DateAdded">   </telerik:GridBoundColumn 
    <telerik:GridBoundColumn SortExpression="Status" HeaderText="Status" HeaderButtonType="TextButton" DataField="Status" UniqueName="Status">    </telerik:GridBoundColumn   
    </Columns   
    <ExpandCollapseColumn Visible="True">  
    </ExpandCollapseColumn 
    </MasterTableView 
    <ExportSettings ExportOnlyData="True" IgnorePaging="True" OpenInNewWindow="True">  
    </ExportSettings> 
    </telerik:RadGrid>

     

    Thanks
    Venkat

  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 07 Jul 2009 Link to this post

    Hello,

    In case you do not want to show ExpandCollapse button inside Excel, please set ExportOnlyData property, which determines whether only data will be exported, to true and let me know if it helps.
    For more information about Exporting, please refer to the following articles:
    Help topic
    Demo

    Kind regards,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. ESM Dev
    ESM Dev avatar
    15 posts
    Member since:
    Apr 2009

    Posted 08 Jul 2009 Link to this post

    Hi,

    ExportOnlyData  property was set to true, still not working.

    Thanks
    Venkat
  7. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 08 Jul 2009 Link to this post

    Hello,

    At this point in order to progress in the resolution of this matter I will ask you to open a formal support ticket and send us a simple running project (incl. CSS, images, skins, DB backup if needed and so on) demonstrating the problem. In that way we can reproduce and pinpoint the problems you're facing on our side, understand the logic of your application and provide a solution.

    Regards,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Joseph
    Joseph avatar
    29 posts
    Member since:
    Jun 2014

    Posted 07 Jul 2014 Link to this post

    Has this been resolved.  I too have a Detailed Report within a MasterTableView that is not expanded when i export to Excel.  Please advice.
  9. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Jul 2014 in reply to Joseph Link to this post

    Hi Joseph,

    Please try the below code snippet on ItemCommand event on export to expand hierarchical grid.

    C#:
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
      if (e.CommandName == RadGrid.ExportToExcelCommandName)
      {
       RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
       RadGrid1.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;
       RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
       RadGrid1.MasterTableView.DetailTables[0].HierarchyLoadMode = GridChildLoadMode.Client;      
       RadGrid1.AllowPaging = false;
       RadGrid1.MasterTableView.DetailTables[0].AllowPaging = false;
       RadGrid1.Rebind();
      }
    }

    Thanks,
    Princy
  10. Joseph
    Joseph avatar
    29 posts
    Member since:
    Jun 2014

    Posted 09 Jul 2014 in reply to Princy Link to this post

    I've tried this and it worked, but what if I have a 3rd Hierarcy DetailTable?  i've tried doing RadGrid1.MasterTableView.DetailTables(0).DetailTables(0).HierarchyDefaultExpanded = True but that didn't work.  Please advice.
  11. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 10 Jul 2014 Link to this post

    Hello Joseph,

    You can try with the following code:
    RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
       
     if (RadGrid1.MasterTableView.HasDetailTables)
     {
       foreach (GridTableView gridTableView in   RadGrid1.MasterTableView.DetailTables)
       {
           gridTableView.HierarchyDefaultExpanded = true;
       }
     }
    RadGrid1.Rebind();

    Regards,
    Pavlina
    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.

     
  12. SABITHA
    SABITHA avatar
    13 posts
    Member since:
    Aug 2013

    Posted 29 Jan 2015 in reply to Pavlina Link to this post

    Hi all,
    I'm having issues in the expand collpase column of the telerik hierrarchy grid . I'm using a link button where it is calling the export to excel () function. Code snippet is as shown below.

    private void lnkExport_Click(object sender, System.EventArgs e)
    {    
    foreach (GridDataItem mItem in uwgTermSheets.MasterTableView.Items)
    {
    mItem.Expanded = true;
    foreach (GridDataItem childItem in mItem.ChildItem.NestedTableViews[0].Items)
    {
    childItem.Expanded = true;
    }
    }
     
    uwgTermSheets.MasterTableView.ExpandCollapseColumn.Exportable = true;
    uwgTermSheets.MasterTableView.ExportToExcel();
    uwgTermSheets.Rebind();
    }
  13. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 02 Feb 2015 Link to this post

    Hi,

    Could you elaborate a bit more on your scenario? What are the exact issues you encounter with the expand collapse column of hierarchy grid? Providing the complete aspx code and the related code behind would help us a lot to understand your scenario better and advice you further.

    Regards,
    Pavlina
    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.

     
  14. SABITHA
    SABITHA avatar
    13 posts
    Member since:
    Aug 2013

    Posted 03 Feb 2015 Link to this post

    Hi,

    I'm attaching the sample code for exporting to the excel from the telerik hierarchical grid,  where I cannot expand and collapse the detailed columns. Please have a look into the attached code. If there is any problem in downloading the files  see the code below for the excel exporting.


    protected void Button1_Click(object sender, EventArgs e)
    {
    RadGrid1.ExportSettings.FileName = "filename";
    RadGrid1.ExportSettings.IgnorePaging = true;
    RadGrid1.ExportSettings.ExportOnlyData = true;
    RadGrid1.ExportSettings.OpenInNewWindow = true;
    RadGrid1.MasterTableView.UseAllDataFields = true;
    RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
    RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
    RadGrid1.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;
    RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
    RadGrid1.MasterTableView.DetailTables[0].HierarchyLoadMode = GridChildLoadMode.Client;
    RadGrid1.MasterTableView.EnableGroupsExpandAll = true;
    RadGrid1.MasterTableView.ExportToExcel();
    }

    Thanks ,
    Sabitha
  15. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 05 Feb 2015 Link to this post

    Hi Sabitha,

    I noticed that my colleague Kostadin has already answered on this question in the other forum thread you have opened: 

    In order to avoid duplicate posts I will ask you to continue your communication there.

    Regards,
    Pavlina
    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017