Epplus - Cannot change cell value or cell header -
i have problem when change value of cell. here code:
fileinfo newfile = new fileinfo(file); excelpackage pck = new excelpackage(newfile); var wsdata = pck.workbook.worksheets.add("absent employee list"); var datarange = wsdata.cells["a1"].loadfromcollection( s in emps orderby s.employeecode select s, true, officeopenxml.table.tablestyles.medium2 ); wsdata.cells[2, 4, datarange.end.row, 4].style.numberformat.format = "dd-mm-yyyy" wsdata.cells[2, 5, datarange.end.row, 5].style.numberformat.format = "dd-mm-yyyy"; wsdata.cells["a1"].value = "employee code"; // [1, 1] wsdata.cells["b1"].value = "full name"; // [1, 2] wsdata.cells["c1"].value = "department"; // [1, 3] datarange.autofitcolumns(); pck.saveas(newfile);
when open file after creating, header of a1, b1, c1 didn't change. did miss something? thank help.
try this
wsdata.cells[1,1].value = "employee code"; wsdata.cells[2,1].value = "full name"; wsdata.cells[3,1].value = "department";
this worked me!
Comments
Post a Comment