java - Set two styles for a single cell -
how can set 2 different styles single cell? showing cell value in
- bold
- currency format eg:
2,300
.
expected o/p: 2,300
but last style overrides earlier one, , can later property.
xssfcellstyle my_style = (xssfcellstyle) wb.createcellstyle(); xssffont my_font=(xssffont) wb.createfont(); my_font.setboldweight(xssffont.boldweight_bold); my_style.setfont(my_font); xssfcellstyle currencyformat = (xssfcellstyle) wb.createcellstyle(); xssfdataformat df =(xssfdataformat) wb.createdataformat(); currencyformat.setdataformat(df.getformat("#,##0"));
setting data here
rowsavingstotal.createcell(a).setcellvalue(2300); rowsavingstotal.getcell(a).setcellstyle(my_style); rowsavingstotal.getcell(a).setcellstyle(currencyformat);
you can put 1 style on cell. merge 2 of them :
xssfcellstyle my_style = (xssfcellstyle) wb.createcellstyle(); xssffont my_font=(xssffont) wb.createfont(); my_font.setboldweight(xssffont.boldweight_bold); my_style.setfont(my_font); xssfdataformat df =(xssfdataformat) wb.createdataformat(); my_style.setdataformat(df.getformat("#,##0"));
rowsavingstotal.createcell(a).setcellvalue(2300); rowsavingstotal.getcell(a).setcellstyle(my_style);