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

Radgrid Export to Excel doesn't export programmatically changed cell format

2 Answers 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ِABC
Top achievements
Rank 1
ِABC asked on 07 Apr 2015, 01:42 PM

Hi All

 I have a question that might be easy to answer, but since I'm new to Telerik, I can't figure out the answer

my situation is like this

I have a RADGRID on a Webform , I changed the Columns backcolor at design time

 and i have to change some cells backcolor programatically according to certain condition 'i.e I change the color of a cell if it has negative value '

 my Problem is

 when i export the RADGRID to Excel with the EXPORT To Excel button of the Commanditem,

i get an excel sheet with the same colors for the columns as they are in the RADGRID

but the programatically changed backcolor for the negative cells are not exported

 it have no backcolor in the produced Excel sheet

 Although I welcome any solution whether C# or VB , I'll be grateful if you provide a solution in VB.NET

 Your Prompt response is highly appreciated

Regards

 

2 Answers, 1 is accepted

Sort by
0
ِABC
Top achievements
Rank 1
answered on 08 Apr 2015, 09:11 AM

This is very urgent and i hope some one gets back with an answer

Thank you

0
Eyup
Telerik team
answered on 10 Apr 2015, 09:30 AM
Hello,

The following configuration works correctly on my side:
<ExportSettings UseItemStyles="true" ExportOnlyData="true"></ExportSettings>
Code-behind:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        item["ShipName"].BackColor = System.Drawing.Color.Lime;
    }
}

Alternatively, you can try:
item["ShipName"].Style["background-color"] = "lime";

You can convert the code snippets here:
http://converter.telerik.com/

Hope this helps.

Regards,
Eyup
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
ِABC
Top achievements
Rank 1
Answers by
ِABC
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or