编程环境vs2017,NPOI2.5
string str = string.Format("第{0}行第{1}列", 1, 3);
IFont fontRed = workbook.CreateFont();
fontRed.Color = HSSFColor.Red.Index;
IRichTextString textString = new XSSFRichTextString(str);
if (Path.GetExtension(fileName).Equals(".xls"))
{
textString = new HSSFRichTextString(str);
}
textString.ApplyFont(3, 6, fontRed);//更改“第3列”颜色为红色
ICell cell = row.CreateCell(j);
cell.SetCellValue(textString);
输出文件结果