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

How to make export excel file with alternating background

1 Answer 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
york
Top achievements
Rank 1
york asked on 01 Jul 2011, 10:29 PM
Hi,
I am exporting radgrid to excel file. I want excel file with background like in attached image. How to do it? Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 04 Jul 2011, 07:06 AM
Hello York,

Try the following code snippet in ExcelExportCellFormatting event to set styles for alternating item when exporting to excel. Hope this helps.

C#:
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
          GridDataItem item = e.Cell.Parent as GridDataItem;
        if (item.ItemType == GridItemType.AlternatingItem)
            item.Style["background-color"] = "Red";
        else
            item.Style["background-color"] = "Blue";
}

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