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

Remove Header Columns when export to excel and CSV

7 Answers 1419 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
bharat veer
Top achievements
Rank 1
bharat veer asked on 12 Aug 2011, 01:57 PM
Hi,

we have a radgrid and we are binding the radgrid with datatable the grid height and width is "0px" while we export to excel or csv we want to remove its header column name is there any possiblities to remove this? Below is my code :

//HTML code
<telerik:RadGrid ID="rgExport" runat="server" Height="0" Width="0"
                    onitemdatabound="rgExporthierarchical_ItemDataBound"
                    onexcelmlexportrowcreated="rgExporthierarchical_ExcelMLExportRowCreated">
                </telerik:RadGrid>

//.CS file Code
rgExport.DataSource=dt;
rgExport.DataBind();

please reply soon we will very thankful to you.

thanks & regards
BHARAT VEER

7 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 15 Aug 2011, 09:59 PM
Hello Bharat,

You can remove the header row by setting ShowHeader to false. Simple demo is shown below:
<asp:Button ID="Button1" runat="server" Text="Export" />
<telerik:RadGrid ID="RG1" runat="server" />


protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
 
    RG1.NeedDataSource += (s, a) =>
        {
            DataTable table = new DataTable();
 
            table.Columns.Add("Column1");
            table.Columns.Add("Column2");
            for (int i = 0; i < 10; i++)
                table.Rows.Add(i, i);
            RG1.DataSource = table;
        };
 
    Button1.Click += (s, a) =>
    {
        RG1.ShowHeader = false;
        RG1.Rebind();
        RG1.MasterTableView.ExportToCSV();
    };
}



Best regards,
Daniel
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.

0
bharat veer
Top achievements
Rank 1
answered on 17 Aug 2011, 01:28 PM
Thanks Daniel !!!!! but it is only working for CSV. It is not working for Excel. Can you please provide me solution for excel as well as. Please reply soon.
0
Princy
Top achievements
Rank 2
answered on 18 Aug 2011, 08:19 AM
Hello Bharat,

You can try the following code snippet to achieve your scenario.

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
      if (e.CommandName == RadGrid.ExportToExcelCommandName)
      {
          GridHeaderItem HeaderItem = (GridHeaderItem)RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0];
          HeaderItem.Visible=false;
      }
}

Thanks,
Princy.
0
Rasheed
Top achievements
Rank 1
answered on 06 Nov 2014, 03:52 PM
I want to remove the header of Detail Table.
How can it possible.
And moreover Itemcommand event is not firing when clicking on Export to Excel button.
0
Eyup
Telerik team
answered on 11 Nov 2014, 12:47 PM
Hello Rasheed,

I've created a sample RadGrid web site to demonstrate how you can achieve the requested functionality. Please run the attached application and let me know if it helps you.

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

 
0
Jorge
Top achievements
Rank 1
answered on 25 Jul 2015, 12:10 PM

Hi

Not work for me!

Please see the picture. I need remove the header row for each DetailTables.

I hope your help!

0
Eyup
Telerik team
answered on 30 Jul 2015, 05:33 AM
Hi Jorge,

Could you share your exporting settings and configuration so I can prepare a web site sample resembling your scenario?

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
bharat veer
Top achievements
Rank 1
Answers by
Daniel
Telerik team
bharat veer
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Rasheed
Top achievements
Rank 1
Eyup
Telerik team
Jorge
Top achievements
Rank 1
Share this question
or