You need to create more that one cell style and then apply the relevant one to 
the cell based upon your condition. So, in pseudocode;

Create grey cell style.
Create white cell style.

if condition
   apply gree cell style to cell
else
   apply white cell style to cell.



"Chaudhary, Harsh" <[EMAIL PROTECTED]> wrote: Hi,

I am writing some POI code and the spreadsheet needs the rows to be
colored in a certain way. For example,

the data looks like:

Index  Value
1  jk
1  oi
2  lkkjhkl
2  iyui
2  iuyjhj
3  ihgh

I would like the rows to be colored like so:

1  jk  (GRAY)
1  oi  (GRAY)

2  lkkjhkl (White)
2  iyui  (White)
2  iuyjhj (White)

3  ihgh  (GRAY)

The way I am thining of doing this is:

I have defined a single style called cellStyle.

if(conditionGray)
{
 cellStyle = code to make cell gary;
 cell.setStyle(cellStyle);
}
else
{
 cellStyle = code to make cell white;
 cell.setStyle(cellStyle);
}

Now when I do this, the cell colors do not change. This leads me to
believe that maybe its not possible to change the style of a cell once
it has been initialized. Is this true?

If not, how do I go about doing this? I would appreciate your help on
this.

Thanks,
HC.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

Reply via email to