C#使用NPOI导出excel设置单元格背景颜色

ICellStyle cellStyle = workbook.CreateCellStyle();
cellStyle.FillPattern = FillPattern.SolidForeground;
cellStyle.FillForegroundColor = 47;
cell.CellStyle = cellStyle;

在设置FillForegroundColor的同时需要设置FillPattern。

FillForegroundColor接收的事一个short类型的值,每个颜色对应的值可以在网上搜一下找到。

posted @ 2018-06-03 15:24  青衫仗剑  阅读(4094)  评论(0编辑  收藏  举报