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. Image for the cookie policy date
close icon

Multiple colored text within an Excel cell

Hello,

Is it possible to do multiple colored text within an Excel cell?

So if I have a cell with the value 'Employee John Smith' is it possible to make 'Employee' grey and 'John Smith' red?

Thanks,
Phil

1 Reply

MR Mahajothi R Syncfusion Team November 6, 2012 05:04 AM UTC

Hi Phil,

 

Thank you for your interest in Syncfusion products.

 

Yes, Our XlsIO support multiple colored text within an excel cell. We have provided the sample with code snippet below for your reference.

 

Sample : RichTextString.zip

 

Code Snippet [C#]:

 

//Insert Rich Text

IRange range = worksheet.Range["C3"];

range.Text = "Employee John Smith";

IRichTextString rtf = range.RichText;

 

//Formatting the text

IFont fontGray = workbook.CreateFont();

fontGray.Size = 16;

fontGray.Bold = true;

fontGray.Italic = true;

//grey color

fontGray.RGBColor = System.Drawing.Color.FromArgb(255, 192, 192, 192);

rtf.SetFont(0, 7, fontGray);

 

IFont fontRed = workbook.CreateFont();

fontRed.Size = 12;

fontRed.Bold = false;

fontRed.Italic = false;

//red color

fontRed.RGBColor = System.Drawing.Color.FromArgb(255, 255, 0, 0);

rtf.SetFont(9, 18, fontRed);

 

Please refer XlsIO Formatting sample in Syncfusion Essential studio dashboard.

Dashboard location : $system drive:\Program Files\Syncfusion\Essential Studio\10.3.0.43\Samples\

 

To know more details on Rich Text please refer this online link : http://help.syncfusion.com/Reporting/XlsIO/WPF

 

Please let us know if you require any further clarifications.

 

Regards,

Mahajothi.


Loader.
Live Chat Icon For mobile
Up arrow icon