c# - NPOI set cell style -


c# or vb.net suggestion welcome.

i have following code create excel file npoi. it's working fine. need apply cell style rows in loops.

dim hssfworkbook new hssfworkbook()      dim sheetone hssfsheet = hssfworkbook.createsheet("sheet1")     hssfworkbook.createsheet("sheet2")     hssfworkbook.createsheet("sheet3")     hssfworkbook.createsheet("sheet4")          dim cellstyle hssfcellstyle = hssfworkbook.createcellstyle     cellstyle.alignment = hssfcellstyle.align_center        = 0 9 step 1         'i want add cell style these cells         sheetone.createrow(i).createcell(1).setcellvalue(i)         sheetone.createrow(i).createcell(2).setcellvalue(i)   next 

how can apply cell style rows in loop above?

you need declare row , cell outside of loop sth this:

dim datacell hssfcell dim datarow hssfrow 

then inside loop, assign value , style cell separately this:

    datarow = sheetone.createrow(i)     datacell = datarow.createcell(1)     datacell.setcellvalue(i)     datacell.cellstyle = cellstyle      datarow = sheetone.createrow(i)     datacell = datarow.createcell(2)     datacell.setcellvalue(i)     datacell.cellstyle = cellstyle 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -