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

Hierarchical Grid Excel Export

5 Answers 214 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pradip
Top achievements
Rank 1
pradip asked on 09 Mar 2009, 05:42 PM

Hi,

I am working on hierarchical grid where I am having 3 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 and PDF. The view under excel should be similar to that on html page.

I am getting that, but there are few problems...

1. For each detail table it is showing me header which I dont want to show. It is working fine for html page but not working for Excel, PDF.

2. I am having total 12 columns of which 3 are having Name, address, origin all are linkbuttons. It is showing me all text as as link in excel which I dont want to show.

3. I dont want to show ExpandCollapse button inside Excel, which is showing presently

Please suggest how to overcome these problems.

Thanks,
Pradip

 

 

 

 

 

5 Answers, 1 is accepted

Sort by
0
pradip
Top achievements
Rank 1
answered on 10 Mar 2009, 02:33 AM
Is there any way I can save the excel rather than directly opening it? I would like to do modification on Excel once i have complete data. I would be looking for adding Top title for the excel.

Thanks,
Pradip
0
Shinu
Top achievements
Rank 2
answered on 10 Mar 2009, 06:22 AM
Hi Pradip,

Try the following code snippet in the Click event of the Export button to hide the headers for the child table.

CS:
  protected void Button1_Click(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true
        RadGrid1.MasterTableView.Rebind(); 
       
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item.Expanded)  
            { 
                foreach (GridTableView childTable in item.ChildItem.NestedTableViews) 
                { 
                  
                    foreach (GridHeaderItem header in childTable.GetItems(GridItemType.Header)) 
                    { 
                        header.Visible = false
                    } 
                } 
            } 
        } 
        
        RadGrid1.ExportSettings.ExportOnlyData = true
        RadGrid1.ExportSettings.OpenInNewWindow = true
        RadGrid1.MasterTableView.ExportToExcel(); 
  
     
        
    } 


Go through the following help article which explains how to export GridButtonColumn data. Go through the section entitled
 'Exporting GridButtonColumn/GridTemplateColumn/GridHyperLinkColumn data'  in the article.
Exporting tips and tricks

You may also refer the application done by telerik in the following forum link and see how the Expand/Collapse column is being hidden in the exported document.
Hiding ExpandColumn on Export

Thanks
Shinu









0
pradip
Top achievements
Rank 1
answered on 12 Mar 2009, 08:27 PM

Hi Shinu,

Thanks for the reply!
 
My grid look like as follows, it is not complete just for your reference....

It is having 2 LinkButtons, when i am exporting this to Excel it is also showing me link. Could you please guide me how to remove these links so that we wont get it in Excel-PDF?

 

<

Columns >

 

 

 

<telerik:GridNumericColumn DataField="division_id" DataType="System.Int64" HeaderText="Division ID" UniqueName="DivisionDivisionID" Visible="false">

 

 

 

 

</telerik:GridNumericColumn>

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="<%$ Resources:Generic, Division %>" UniqueName="DivisionDivision" DataField="division_name" >

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

<asp:LinkButton id="lnkDivisionName" Font-Bold="true" ForeColor="Navy" text='<%# Container.DataItem("division_name")%>' CommandName="ExpandCollapse" runat="server" ToolTip="Click to expand/collapse the Site information for this Division" >

 

 

 

 

</asp:LinkButton>

 

 

 

</ItemTemplate>

 

 

 

 

<HeaderStyle Width="147px" />

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

<telerik:GridNumericColumn DataField="division_id" DataType="System.Int64" HeaderText="Division ID" UniqueName="DivSiteDivisionID" Visible="false">

 

 

 

 

</telerik:GridNumericColumn>

 

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="<%$ Resources:Generic, Site %>" UniqueName="DivisionSite">

 

 

 

 

<ItemTemplate>

 

 

 

 

 

<asp:LinkButton id="lnkDivisionSiteName" ForeColor="Navy" text='<%# Container.DataItem("site_name")%>' CommandName="ExpandCollapse" runat="server" ToolTip="Click to expand/collapse the Account information for this Site">

 

 

 

 

</asp:LinkButton>

 

 

 

 

</ItemTemplate>

 

 

 

 

<HeaderStyle Width="149px" />

 

 

 

 

</telerik:GridTemplateColumn>..................
.............

Thanks,
Pradip

 

0
Shinu
Top achievements
Rank 2
answered on 13 Mar 2009, 08:10 AM
Hi Pradip,

Have you set ExportOnlyData to true in the Click event of the Export button? If not try setting it to true and see whether the linkbuttons are getting removed.

CS:
        RadGrid1.ExportSettings.ExportOnlyData = true;  
        RadGrid1.MasterTableView.ExportToExcel();  

Shinu
0
pradip
Top achievements
Rank 1
answered on 13 Mar 2009, 12:05 PM
yes i am using that ExportOnlyData but still showing links... Any more help will be good for me.

Thanks,
Pradip
Tags
Grid
Asked by
pradip
Top achievements
Rank 1
Answers by
pradip
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or