c# - Set Gridline Color Using EPPlus? -
is possible set worksheet's gridline color using epplus?
the "gridline color" option i'm trying set programmatically shown in screenshot below.
i dont see option in epplus. manually set attributes using xml:
[testmethod] public void sheet_gridline_color_test() { //http://stackoverflow.com/questions/29380587/set-gridline-color-using-epplus //throw in data var dtmain = new datatable("tbldata"); dtmain.columns.add(new datacolumn("col1", typeof(int))); (var = 0; < 20; i++) { var row = dtmain.newrow(); row["col1"] = i; dtmain.rows.add(row); } var existingfile = new fileinfo(@"c:\temp\temp.xlsx"); if (existingfile.exists) existingfile.delete(); using (var pck = new excelpackage(existingfile)) { var ws = pck.workbook.worksheets.add("content"); ws.cells["a1"].loadfromdatatable(dtmain, true); //can xml elements quick , dirty using relative childs should proper search in production var wsxd = ws.worksheetxml; var wsxml = wsxd.lastchild; //gets 'worksheet' var sheetviewsxml = wsxml.firstchild; //gets 'sheetviews' var sheetviewxml = sheetviewsxml.firstchild; //gets 'sheetview' var att = wsxd.createattribute("defaultgridcolor"); att.value = "0"; sheetviewxml.attributes.append(att); att = wsxd.createattribute("colorid"); att.value = "10"; sheetviewxml.attributes.append(att); pck.save(); } }
Comments
Post a Comment