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


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

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

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM