I have a problem when change the value of a cell. Here is my 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(
from 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 I open the file after creating, the header of A1, B1, C1 didn't change. Did i miss something? thank you for your help.
Try this
wsData.Cells[1,1].Value = "Employee Code";
wsData.Cells[2,1].Value = "Full Name";
wsData.Cells[3,1].Value = "Department";
This is what worked for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With