I'm having trouble with format my cells to Date.
FileInfo info = new FileInfo(path); using (ExcelPackage package = new ExcelPackage(info)) { ExcelWorksheet ws = package.Workbook.Worksheets.Add(sheetName); ws.Cells[3, 1].Style.Numberformat.Format = "yyyy-mm-dd"; ws.Cells["A3"].Formula = "=DATE(2014,10,5)"; }
Output from this in Excel: 41 917,00
Why is this not working?
Format = "yyyy-mm-dd"; ws. Cells[3, 1]. Value = new DateTime(2014,10,5); ws.
EPPlus does not work with the XLS format. Only XLSX. You'll need to find a new library.
EPPlus is a very helpful open-source 3rd party DLL for writing data to excel. EPPlus supports multiple properties of spreadsheets like cell ranges, cell styling, charts, pictures, shapes, comments, tables, protection, encryption, pivot tables, data validation, conditional formatting, formula calculation, etc.
I agree with Yosoyke. You're probably targeting the wrong cells. You can try:
ws.Cells["A3"].Style.Numberformat.Format = "yyyy-mm-dd"; ws.Cells["A3"].Formula = "=DATE(2014,10,5)";
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