Example for DotNetCore.NPOI:
var newFile = @"newbook.core.xlsx";
using (var fs = new FileStream(newFile, FileMode.Create, FileAccess.Write))
{
var workbook = new XSSFWorkbook();
var sheet = workbook.CreateSheet("Sheet1");
var rowIndex = 0;
var row = sheet.CreateRow(rowIndex);
var cell = row.CreateCell(0);
var text = "this is content";
cell.SetCellValue(text);
var font = workbook.CreateFont();
font.Color = HSSFColor.Blue.Index2;
cell.RichStringCellValue.ApplyFont(text.Length - 4, text.Length, font);
workbook.Write(fs);
}
The code also works for .NET framework and NPOI nuget package.
Result:

Cell has property RichStringCellValue
. You can call ApplyFont
method on RichStringCellValue
and specify the range where the font will be applied.