You have to make sure you cast your font to XSSFFont
first, IFont does not offer access to the RGB color properties of the font.
You can then set the color using an XSSColor
, which can either be constructed from a byte array or a System.Drawing.Color object.
Example code, different varieties of the constructor in comments:
var wb = new XSSFWorkbook();
var sheet = wb.CreateSheet("Sheet 1");
// Create a colored font
var font = (XSSFFont) wb.CreateFont();
// var color = new XSSFColor(ColorTranslator.FromHtml("#C88C14"));
// var color = new XSSFColor(new Color(255, 255, 255));
var color = new XSSFColor(new byte[] {200, 140, 20});
font.SetColor(color);
// Create a dedicated cell style using that font
var style = wb.CreateCellStyle();
style.SetFont(font);
// Create some cell values
var row = sheet.CreateRow(0);
row.CreateCell(0).SetCellValue("Standard text");
var cell = row.CreateCell(1);
cell.SetCellValue("Colored text");
// Apply the cellstyle we created
cell.CellStyle = style;