zony.me

NPOI 自定义单元格背景颜色

首先,单元格背景颜色的Style里面的属性不是"FillBackgroundColor",正确的应该是FillForegroundColor。 其次我们不仅仅需要设置颜色,而且还要设置该style的FillPattern。 下面是代码:

C#
ICellStyle style = workbook.CreateCellStyle();
style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Red.Index;
style.FillPattern = FillPattern.SolidForeground;
ICell cell = workbook.CreateSheet().CreateRow(0).CreateCell(0);cell.CellStyle = style;
NPOI 自定义单元格背景颜色
作者 Zony · 发布于 2016-09-29
Licensed under CC BY-NC-SA 4.0
← 上一篇定时事件任务池下一篇 →Visual Studio 开发 .NET Core 站点