Styling Excel Export

4 posts, 0 answers
  1. Arya
    Arya avatar
    1 posts
    Member since:
    May 2011

    Posted 11 May 2011 Link to this post

    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 = ??

  2. Vlad
    Vlad avatar
    11100 posts

    Posted 12 May 2011 Link to this post

    Hello Arya,

     I strongly suggest you to check our demos.

    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
  3. Anne Lyon
    Anne Lyon avatar
    90 posts
    Member since:
    Jan 2010

    Posted 13 Jan 2015 Link to this post

    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.
  4. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 14 Jan 2015 Link to this post


    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.


    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.

Back to Top