NPOI: установите цвет ячейки на пользовательский цвет ⇐ C#

Место общения программистов C#
Anonymous
NPOI: установите цвет ячейки на пользовательский цвет

Сообщение Anonymous »

Как установить цвет ячейки на пользовательский цвет, используя C# npoi?XSSFCellStyle cellStyle = (XSSFCellStyle)workbook.CreateCellStyle();
cellStyle.FillBackgroundColor = IndexedColors.LightCornflowerBlue.Index;
cellStyle.FillForegroundColor = IndexedColors.LightCornflowerBlue.Index;
cellStyle.FillPattern = FillPattern.SolidForeground;
ICell cell = CurrentRow.CreateCell(CellIndex);
cell.CellStyle = cellStyle;
< /code>
Однако я хочу использовать пользовательский цвет. IndexedColors ограничена и не так полезна.
Я давно просматривал ответ. SetFillForegroundColor теперь короткий и больше не является XSSFColor. < /P>
byte[] rgb = new byte[3] { 192, 0, 0 };
XSSFCellStyle HeaderCellStyle1 = (XSSFCellStyle)xssfworkbook.CreateCellStyle();
HeaderCellStyle1.SetFillForegroundColor(new XSSFColor(rgb));


Подробнее здесь: https://stackoverflow.com/questions/652 ... stom-color

Вернуться в «C#»