俩种设置单元格背景色的方法
//方法1
XSSFCellStyle rowsStyleColor = (XSSFCellStyle)xssfworkbook.CreateCellStyle();
XSSFColor xssfColor = new XSSFColor();
//根据自己需要设置RGB
byte[] colorRgb = { (byte)252, (byte)139, (byte)139 };
xssfColor.SetRgb(colorRgb);
rowsStyleColor.FillForegroundColorColor = xssfColor;
rowsStyleColor.FillPattern = FillPattern.SolidForeground;
//方法2
ICellStyle rowsStyleColor = (XSSFCellStyle)xssfworkbook.CreateCellStyle();
rowsStyleColor.Alignment = HorizontalAlignment.Center;
rowsStyleColor.VerticalAlignment = VerticalAlignment.Center;
rowsStyleColor.BorderBottom = BorderStyle.Thin;
rowsStyleColor.BorderLeft = BorderStyle.Thin;
rowsStyleColor.BorderRight = BorderStyle.Thin;
rowsStyleColor.BorderTop = BorderStyle.Thin;
rowsStyleColor.WrapText = true;
//设置背景颜色...
rowsStyleColor.FillForegroundColor = 0;
rowsStyleColor.FillPattern = FillPattern.SolidForeground;
((XSSFColor)rowsStyleColor.FillForegroundColorColor).SetRgb(new byte[] { 252, 139, 139 });