1

I know how to format cell values in EPPlus but only if the format applies to the whole value. How can I add formatting that only applies to part of the cell value?

for example...

enter image description here

Simon Keep
  • 9,886
  • 9
  • 63
  • 78
  • Possible duplicate of [How can I create multistyled cell with EPPlus library for Excel](http://stackoverflow.com/questions/9973240/how-can-i-create-multistyled-cell-with-epplus-library-for-excel) – Simon Keep Sep 29 '16 at 13:15

1 Answers1

1

Use the RichText collection to build it:

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();
}
Ernie S
  • 13,902
  • 4
  • 52
  • 79