Skip to content

How set the cell color to a user defined value? #1244

Closed Answered by toraritte
toraritte asked this question in Q&A
Discussion options

You must be logged in to vote

I failed to notice that a cell's CellStyle property returns the generic ICellStyle, which has to be cast down to NPOI.XSSF.UserModel.XSSFCellStyle in order to gain access to the FillBackgroundXSSFColor and FillForegroundXSSFColor properties.

Also, here's a summary of which property does what, quoting from this answer:

As said in my linked answer: Cell interior uses pattern fills. The fill background color is the color behind the pattern.The fill foreground color is the color of the pattern. To fill the cell using a plain color, you need using fill foreground color CellStyle.setFillForegroundColor and solid pattern FillPatternType.SOLID_FOREGROUND.

In my case, I need NPOI.SS.UserModel.Fi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by toraritte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant