如何使用closedxml在同一个excel单元格中制作不同颜色的文本

问题描述:

如何使用closedXML在同一个excel单元格中制作不同颜色的文本





ClosedXML没有像我在下面尝试的那样请帮我在同一个单元格中制作2种不同的字体颜色



我尝试了什么:



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

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

我自己找到了解决方案

使用RichText来设置单元格的不同部分,例如:

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.