如何使用 EPPlus 在仅适用于部分单元格值的单元格中添加格式?

How can I add formatting within a cell that only applies to part of the cell value using EPPlus?

我知道如何在 EPPlus 中设置单元格值的格式,但前提是该格式适用于整个值。如何添加仅适用于单元格值的 部分 的格式?

例如...

使用 RichText 集合构建它:

using (var pck = new ExcelPackage())
{
    var wb = pck.Workbook;
    var ws = wb.Worksheets.First();

    var cell = ws.Cells["B2"];
    cell.RichText.Add("This is some ");
    cell.RichText.Add("formatting");
    cell.RichText.Add(" withing a value");

    cell.RichText[1].Color = Color.Red;
    cell.RichText[1].Size = 14;

    pck.Save();
}