更改单元格的值时出现问题。这是我的代码:
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);
创建后打开文件时,A1,B1,C1的标题没有改变。我错过了什么?感谢您的帮助。