我们刚开始使用 NPOI 组件。
我们在设置 ICellStyle 属性的 FillForegroundColor 时遇到问题。
ICellStyle HeaderCellStyle = xssfworkbook.CreateCellStyle();
HeaderCellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.RED.index;
FillForegroundColor 需要短类型。
我们如何设置不同的颜色而不是使用 HSSFColor 中的颜色。
我们需要设置为 "RGB192:0:0"
以及我们如何为 ICellStyle 属性 FillForegroundColor 设置
有人可以通过一些例子帮助我们吗?
最佳答案
我自己找到了解决方案。请引用下面的代码
byte[] rgb = new byte[3] { 192, 0, 0 };
XSSFCellStyle HeaderCellStyle1 = (XSSFCellStyle)xssfworkbook.CreateCellStyle();
HeaderCellStyle1.SetFillForegroundColor(new XSSFColor(rgb));
关于c# - ICellStyle FillForegroundColor 的自定义颜色比提供的命名颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22687901/