c# - Unable to set FillBackgroundColor -


i'm using npoi 2.0.6.0 in c# project , i'm running difficulty changing styling. while can affect font , cell borders cannot change background color.

private void buildsheet(hssfworkbook wb, datatable data, string sheetname) {     var chelp = wb.getcreationhelper();     var sheet = wb.createsheet(sheetname);      hssffont hfont = (hssffont)wb.createfont();      hfont.boldweight = (short)fontboldweight.bold;     hfont.color = hssfcolor.white.index;     hfont.fontheightinpoints = 18;      hssfcellstyle hstyle = (hssfcellstyle)wb.createcellstyle();     hstyle.setfont(hfont);     hstyle.borderbottom = borderstyle.medium;     hstyle.fillbackgroundcolor = hssfcolor.black.index;      irow headerrow = sheet.createrow(1);       int cellcount = 1;     foreach (string str in colheaders)     {         hssfcell cell = (hssfcell)headerrow.createcell(cellcount);         cell.setcellvalue(chelp.createrichtextstring((str)));         cell.cellstyle = hstyle;          cellcount += 1;     }      int rowcount = 2;     foreach (datarow dr in data.rows)     {         var row = sheet.createrow(rowcount);         (int = 1; < data.columns.count + 1; i++)         {             row.createcell(i).setcellvalue(chelp.createrichtextstring((dr[i - 1]).tostring()));         }         rowcount += 1;     } } 

after attaching debugger noticed hstyle.fillbackgroundcolor never changes 0x0040 despite index of black 8.

so question is:

  • why hssfcellstyle.fillbackgroundcolor not modifiable?

a fillbackgroundcolor cannot applied without specifying fillpattern.

i.e.

        hstyle = (hssfcellstyle)workbook.createcellstyle();         hstyle.setfont(xfont);         hstyle.borderbottom = borderstyle.medium;         hstyle.fillforegroundcolor = indexedcolors.black.index;         hstyle.fillpattern = fillpattern.solidforeground; 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -