Hello,
I have the following method that I would like to call to change the Color of the referenced cell. (See bottom of method).
The logic is to use a Case statment to determine which Color to use. I will eventually have up to TEN Colors to pick from.
When I run against the method below, the referenced cells color displays as BLACK not the nice hue of Yellow I wanted for example.
I appreciate any ideas. In short, I want to change the Color on the fly so, to speak.
Thanks
private void setCertNameStyle(Worksheet s, Workbook b) {
Font font = null;
Color cCertColor = null;
gColorPicker++;
String colorPickerName = String.valueOf(gColorPicker);
//Adding a new Style to the styles collection of the Excel object
Style style = b.createStyle();
style.setName("certStyle"+colorPickerName);
switch (gColorPicker) {
case 1: cCertColor = new Color((short)255,(short)204,(short)153); break;
case 2: cCertColor = new Color((short)255,(short)255,(short)153); break;
default: cCertColor = new Color((short)255,(short)204,(short)153); break;
}
// set selected cell color
style.setColor(cCertColor);
// set text to center
style.setHAlignment(TextAlignmentType.CENTER);
// set font
font = style.getFont();
font.setBold(true);
font.setSize(11);
style.setFont(font);
// set the final style for the cell
s.getCells().getCell(gRow,0).setStyle(style);
}