Wasim Shaikh Wasim Shaikh - 1 year ago 139
ASP.NET (C#) Question

How to use different colors of texts in same Excel cell using ClosedXML?

How to use different colors of texts in the same Excel cell using ClosedXML?

worksheet.Cell(1,1).Value.Character[StartIndex, NoOfChar].Font.Color....??


ClosedXML doesn't have something like above, please help me to use two different font colors in the same cell.

Answer Source

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.