NPOI: Setzen Sie die Zellfarbe auf eine benutzerdefinierte FarbeC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 NPOI: Setzen Sie die Zellfarbe auf eine benutzerdefinierte Farbe

Post by Anonymous »

Wie setzen Sie die Zellfarbe mit C# npoi auf eine benutzerdefinierte Farbe ein?

Code: Select all

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>
Ich möchte jedoch eine benutzerdefinierte Farbe verwenden. Die IndexedColors sind begrenzt und nicht so nützlich. Ab vor Jahren, aber es scheint nicht mehr relevant zu sein. SetFillforegroundColor ist jetzt kurz und nicht mehr XSSFColor. < /P>
byte[] rgb = new byte[3] { 192, 0, 0 };
XSSFCellStyle HeaderCellStyle1 = (XSSFCellStyle)xssfworkbook.CreateCellStyle();
HeaderCellStyle1.SetFillForegroundColor(new XSSFColor(rgb));

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post