Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: How get cell background color in RGB value?

$
0
0
Interested reading date with cell format + attributes, with NPOI.

Previous, I used to work with the VBA and the color value I get through these settings.
For foreground color used this for VBA:
ActiveCell.Font.ColorIndex // getting index color, like 28
ActiveCell.Font.Color // for getting RGB color, return value like 16776960, this is value for RGB(255,255,0)

For background color used this for VBA:
ActiveCell.Interior.ColorIndex // getting index color, like 28
ActiveCell.Interior.Color // for getting RGB color, return value like 16776960, this is value for RGB(255,255,0)

I try this code with NPOI:
XSSFCell cell = sheet.GetRow(0).GetCell(0) as XSSFCell;  
ICellStyle cellStyle = cell.CellStyle;
IColor fillBackgroundColorColor = cellStyle.FillBackgroundColorColor;
byte[] argb = fillBackgroundColorColor.RGB;
But last row is no rgb color from cell.
But I only get index color (like ActiveCell.Font.ColorIndex).
When you work through library NPOI, I only get the color index and can not get the RGB color.
Tell me please, is not possible to obtain a more accurate color? And the background color as you can not?
Tell me please, how you can extract from a cell RGB accurate color, not just the standard color index. Thank you.

Viewing all articles
Browse latest Browse all 1621

Trending Articles