Export radgrid to Excel, not exporting the column headers.

6 posts, 0 answers
  1. Gaurav
    Gaurav avatar
    6 posts
    Member since:
    Apr 2011

    Posted 12 Apr 2011 Link to this post

    i want to export radgrid in excel with column names (Header Texts). Am using below code to achieve this :-


    but it exports the data without header text,whereas i want to export the data with header text.

    I am making div containing the grid as invisible at run time, which is my requirement.

    Is there any way to export column headers too along with the data ??

    Note :- I cannot show the grid on the page as it is specially created for the purpose of export.

    Any kind of help will be highly appreciated
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Apr 2011 Link to this post

    Hello Gaurav,

    I have found this forum discussed similar scenario.
    Header is not exporting during export to excel

  3. Gaurav
    Gaurav avatar
    6 posts
    Member since:
    Apr 2011

    Posted 12 Apr 2011 Link to this post

    Thanks for the reply shinu, but it din't help me.
    I want to modify my post, the columns are not generated dynamically in my case.
    The grid is being bound to a data source and i have specified the data field properties for the columns in aspx page.

    Any idea why Column headers are not getting exported.
  4. Daniel
    Daniel avatar
    4949 posts

    Posted 14 Apr 2011 Link to this post

    Hello Gaurav,

    Please try the code-snippet posted in this thread:
    Link to public post

    Kind regards,
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. sanoj
    sanoj avatar
    1 posts
    Member since:
    Jul 2014

    Posted 04 Jul 2014 Link to this post

    Even i am facing the same issue.
    if the radgrid being exported to excel is invisible, the excel is losing the column headers.

  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2014 in reply to sanoj Link to this post

    Hi Sanoj,

    The headers won't be exported properly if your RadGrid is invisible. You can set the radgrid visibility to True on the Export button click, this will not display the control on the page. Please take a look at the sample code snippet.

    <asp:Button ID="btnExport" runat="server" Text="Export" OnClick="btnExport_Click" />
    <asp:Button ID="btnHide" runat="server" Text="Hide" OnClick="btnHide_Click" />
    <telerik:RadGrid ID="rgrdExport" runat="server" AutoGenerateColumns="false" DataSourceID="dsGridDetails" AllowPaging="true>
        <MasterTableView >
                <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" />        
                <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" />

    protected void btnExport_Click(object sender, EventArgs e)
        rgrdExport.Visible = true;
        rgrdExport.ExportSettings.IgnorePaging = true;
        rgrdExport.ExportSettings.ExportOnlyData = true;
    protected void btnHide_Click(object sender, EventArgs e)
        rgrdExport.Visible = false;

Back to Top