java - Apache POI Excel row color is only black and doesn't change -
i trying make excel files background 1 row white , other aqua color. reason whatever color changes black.
private void writetable(table table, row row, cellstyle style){ if(row.getrownum() % 2 == 0) { style.setfillbackgroundcolor(indexedcolors.aqua.getindex()); style.setfillpattern(cellstyle.solid_foreground); } style.setwraptext(true); cell cell = row.createcell(0); cell.setcellvalue(table.index); cell.setcellstyle(style); //and continues other cells }
it doesn't change whatever do, if try grey_25_percent black. here's picture of excel file
if setting foreground color, use
cellstyle.setfillpattern(fillpatterntype.solid_foreground);
if setting background color, use
style.setfillpattern(fillpatterntype.thick_backward_diag);
or
style.setfillpattern(fillpatterntype.thin_backward_diag);
the foreground , background colors seem 'stack' (red + blue = purple) if set foreground fill pattern before background fill pattern, not other way round. there several other fill patterns can choose from. note color not applied if not change default fill pattern.
Comments
Post a Comment