设置单元的背景颜色
为了将细胞的后发现颜色设置为RGB = 198,224,180(一种绿色调),我正在使用以下内容:
ICellStyle style = wb.CreateCellStyle();
var font = (XSSFFont)GetGroupFont(wb);
style.SetFont(font);
var backColor = new XSSFColor(new byte[] { 198, 224, 180 });
style.FillForegroundColor = backColor.Index;
style.FillPattern = FillPattern.SolidForeground;
style.Alignment = HorizontalAlignment.Left;
style.VerticalAlignment = VerticalAlignment.Center;
ICell cellGroup = row.CreateCell(0);
cellGroup.CellStyle = style;
cellGroup.SetCellValue(value);
与上述内容,所得的Excel显示了具有黑色背景的单元格。怎么了?
To set cell backgound color to RGB = 198, 224, 180 (a green tonality) I am using this:
ICellStyle style = wb.CreateCellStyle();
var font = (XSSFFont)GetGroupFont(wb);
style.SetFont(font);
var backColor = new XSSFColor(new byte[] { 198, 224, 180 });
style.FillForegroundColor = backColor.Index;
style.FillPattern = FillPattern.SolidForeground;
style.Alignment = HorizontalAlignment.Left;
style.VerticalAlignment = VerticalAlignment.Center;
ICell cellGroup = row.CreateCell(0);
cellGroup.CellStyle = style;
cellGroup.SetCellValue(value);
With the above, the resulting Excel shows a cell with black background. What's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论