Click here to Skip to main content
15,889,354 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to make different colors of texts in same excel cell using closedXML


ClosedXML doesn't have something like I tried below please help me to make 2 different font colors in same cell

What I have tried:

worksheet.Cell(1,1).Value.Character[StartIndex, NoOfChar].Font.Color....??
Posted
Updated 21-Sep-16 3:37am

1 solution

I found the solution by my self
Use RichText to style different parts of the cell, for example:
worksheet.Cell(1,1).RichText.Substring(StartIndex, NoOfChar).SetFontColor(XLColor.Red);

See the [documentation] for more details.
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 21-Sep-16 12:09pm    
5, Good that you have posted the solution, it might help someone in future.
IamWsk 22-Sep-16 4:03am    
Thanks karthik..Definitely it will help the people in future.
Karthik_Mahalingam 22-Sep-16 5:59am    
:) cool
[no name] 22-Sep-16 2:15am    
Here are some other solutions to achieve this task: How can I change color of text in cell of Excel
IamWsk 22-Sep-16 4:01am    
Yes it is also a solution but it is for interop users.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900