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

RadGrid Export to Excel missing column name in excel file

2 Answers 281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
thecruciable
Top achievements
Rank 1
thecruciable asked on 12 Aug 2009, 06:45 PM
Hello,

I have a RAD Grid within an asp panel and I am setting the panel's visibility to false. I binding data to this grid and then doing an export to excel on button click event. Since the panel's visibility is set to false the data for the column is exported and the column name does not appear. If I set the panel's visibility to true I can both data and the column name in the excel. This is my code hope somebody can help me on this:
ASPX code:
<asp:Panel ID="pnlGridDisplay" runat="server" Visible="false">           
            <telerik:RadGrid runat="server" ID="rgGrid" GridLines="None" AllowSorting="true" AllowPaging="false"
                AllowFilteringByColumn="false" PageSize="30" AutoGenerateColumns="false" ShowGroupPanel="true" ShowFooter="false"
                Width="200">
                <MasterTableView DataKeyNames="GradID">
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="ID" DataField="ID" UniqueName="ID" Visible="false"/>
                        <telerik:GridBoundColumn HeaderText="Email" DataField="Email" SortExpression="Email" UniqueName="Email"/>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </asp:Panel>       

C# code:
 protected void btnExportRegistered_Click(object sender, EventArgs e)
        {
            rgGrid.DataSource = ds;
            rgGrid.DataBind();
            rgGrid.GridLines = GridLines.Both;
            rgGrid.ExportSettings.IgnorePaging = true;
            rgGrid.ExportSettings.ExportOnlyData = true;
            rgGrid.ExportSettings.OpenInNewWindow = true;
            rgGrid.MasterTableView.ExportToExcel();
        }   

So I get the excel file with bunch of email address's but no column name.

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 12 Aug 2009, 08:24 PM
Hello Amitesh,

Make sure that your RadGrid is visible before export, otherwise the header row won't be visible:
ASP.NET Controls - Grid Forum - Column headers on Excel export?

Best regards,
Daniel
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.
0
thecruciable
Top achievements
Rank 1
answered on 13 Aug 2009, 11:49 AM
It worked thank you very much.
Tags
Grid
Asked by
thecruciable
Top achievements
Rank 1
Answers by
Daniel
Telerik team
thecruciable
Top achievements
Rank 1
Share this question
or