Thanks Steve.But iam using different styles for different objects.For example
for date iam using
HSSFCellStyle csDate = wb.createCellStyle();
HSSFCellStyle csDouble = wb.createCellStyle();
I have different styles for different datatypes such as double etc..
So based on the row count i can set the color,but if iam using following
code.
Iam looping through row and for each cell iam checking the datatype.
if(value instanceof Double)
{
if(!(rownum%2==0))
{
csDouble.setFillForegroundColor(HSSFColor.AQUA.index);
csDouble.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
}
}
So iam using many styles in a row,i mean for different cells i have
different styles.So if iam using above code and setting color.That color is
being applied through out the sheet.
So any solution please??
Steve Klimchuk wrote:
>
> Try this...
>
> HSSFCellStyle altRow = workbook.createCellStyle();
> altRow.setFillForegroundColor(HSSFColor.AQUA.index);
> altRow.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
>
> if((rownum % 2) == 1) {
> cell.setCellStyle(altRow);
> }
>
>
>
>
>
>
>
> suriz4u wrote:
>> In my application there is requirement that alternative rows should be
>> colored.As iam using different styles for different
>> objects(Ex:Long,Integer,Float etc..).I tried to use in following way for
>> different objects
>>
>> HSSFCellStyle csDouble= wb.createCellStyle();
>> if(!(rowNumber%2==0))
>> { csDouble.setFillForegroundColor(HSSFColor.AQUA.index);
>> csDouble.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);}
>>
>>
>> But to my surprise i got all the rows with same color.Iam really
> confused.
>> Can any one help me out please..............
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Needs-help-regarding-coloring-alternate-rows.............-tp17731174p17747577.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]