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

Styling Excel Export

3 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arya
Top achievements
Rank 1
Arya asked on 11 May 2011, 11:31 PM
Hi,
 
I have a very complicated business logic by which I color each cell in a RadGridView.
This color logic is implemented in a web service.
In the final data source, each data cell comes with its own color based on this logic and a cell level style selector assigns each cell with its appropriate color.

I want to export to excel and retain that coloring. Is it possible?

void theDataGrid_Exporting(object sender, GridViewExportEventArgs e)
{
    if (e.Element == ExportElement.Cell)
    {
        e.background = ??
    }
}

Thanks
Arya

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 May 2011, 06:39 AM
Hello Arya,

 I strongly suggest you to check our demos.

Regards,
Vlad
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Anne Lyon
Top achievements
Rank 1
answered on 13 Jan 2015, 10:33 AM
Hello,
picking up this old post as I haven't found an answer to my problem which is similar to the one above: I want to export a grid where each cell potentially can have a different background color. In Grid_Exporting I need to check the background color of each Export Element of type Cell and set the Style based on the Background. I can do this if the whole column has a backGround but not if I need to look in each cell.
In Your demo you set individual colors/styles based on e.Value (which is easy to find) or e.Context's UniqueName (all values on column Level are easy to find), but how can I check which Style to set based on background in a cell? e.Background is always null, and I understand it is obsolete anyway.
Do you have any suggestion? Originally I set the cellBackground by binding the CellStyle property for the Column, but if there are other ways of setting individual cell backgrounds in the GridView which makes the background detectable while exporting I am happy to change my code.
Thanks for any input.
0
Dimitrina
Telerik team
answered on 14 Jan 2015, 11:51 AM
Hi,

As it turns out, currently this is all the information available with the GridViewElementExportingEventArgs and there is not a better approach to suggest when exporting via the Export method. I can also suggest you checking the alternative approach illustrated in our "SpreadProcessing Integration" WPF Demo.

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

 
Tags
GridView
Asked by
Arya
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Anne Lyon
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or