We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Howto Set the Font Color to a custom value in a cell IStyle

Thread ID:

Created:

Updated:

Platform:

Replies:

125066 Jul 19,2016 09:57 AM UTC Jul 20,2016 07:33 AM UTC WPF 1
loading
Tags: XlsIO
sabrina c.
Asked On July 19, 2016 09:57 AM UTC

Hi,
I am working on exporting a SfDatagrid in Excel. I'm implementing cell styles to be able to modify the aspects of the various cells in excel to reflect the SfDataGrid coloring.
As stated in the Subject, I've found how to set the background color, the border and font size and type.
Unfortunately there is no way to set the Foreground of the cell in the style and the font color asks for an "ExcelKnownColor".

Is there a way to convert a custom html format color like "#FFCCEE" to an "ExcelKnownColor"? I'm sure that excel is able to get any kind of RGB combination of colors so this enumeration is really strange to use.

it would be nice to have a Foreground color property in the IStyle similar to the one used for the cell background color.

thank you in advance
Regards
Sabrina

Kesavan D [Syncfusion]
Replied On July 20, 2016 07:33 AM UTC

Hi Sabrina, 

Thank you for contacting Syncfusion support. 

XlsIO allows to set custom colors in CellStyle and Font as shown in the below code sample. 

Code snippet: 

    //Set custom font color 
    worksheet.Range["A1"].CellStyle.Font.RGBColor = System.Drawing.ColorTranslator.FromHtml("#FFCCEE"); 
    worksheet.Range["A1"].Text = "Color"; 
             
    //Set custom cell style color 
    worksheet.Range["A2"].CellStyle.Color = System.Drawing.ColorTranslator.FromHtml("#FFCCEE"); 



We have prepared a sample which illustrates the same and can be downloaded from the below link. 


Kindly verify the sample and let us know if your requirement is fulfilled. 

Regards, 
Kesavan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;