ICellStyle cellStyle = workbook.CreateCellStyle(); cellStyle.FillPattern = FillPattern.SolidForeground; cellStyle.FillForegroundColor = 47; cell.CellStyle = cellStyle;
在設置FillForegroundColor的同時需要設置FillPattern。
FillForegroundColor接收的事一個short類型的值,每個顏色對應的值可以在網上搜一下找到。