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

Format Heading Background Color when Exporting

2 Answers 222 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ttaylor29
Top achievements
Rank 1
ttaylor29 asked on 28 Nov 2012, 03:42 PM
What is the code to change the Heading background colors when exporting to excel from a rad grid?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Nov 2012, 05:49 AM
Hi,

Please try the following code snippet to give Background color when exporting.

C#:
protected void RadGrid1_ExcelExportCellFormatting(object sender, ExcelExportCellFormattingEventArgs e)
{
    if (e.Cell.Parent is GridHeaderItem)
    {
        GridHeaderItem item = e.Cell.Parent as GridHeaderItem;
        item.Style["background-color"] = "#359AFF";
    }
}

Regards,
Princy.
0
ttaylor29
Top achievements
Rank 1
answered on 29 Nov 2012, 01:12 PM
I tried the code you posted below and I couldn't get it to work. I put it in debug mode and that line of code was never processed.

I did get the below code to work though:

foreach (GridHeaderItem Header in radgrid1.MasterTableView.GetItems(GridItemType.Header))
{
    Header.BackColor = System.Drawing.Color.Black;
    Header.ForeColor = System.Drawing.Color.White;
}

Thanks for the response.
Tags
Grid
Asked by
ttaylor29
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
ttaylor29
Top achievements
Rank 1
Share this question
or