I am using EPPlus excelpackage
with c#
to get values from a spreadsheet
. The spreadsheet has two separate columns Date
and Time
. The issue is the date value is 2/4/2020
but it returns as 2/4/2020 12:00:00 AM
. The time value is 12:21 AM
but it returns 12/30/1899 12:21:00 PM
. My desired result is to return the values as they are in the spreadsheet
. I am not clear on why this is happening or how to fix the issue for my needs.
using (ExcelPackage package = new ExcelPackage(fs))
{
ExcelWorkbook excelWorkBook = package.Workbook;
ExcelWorksheet ws = excelWorkBook.Worksheets.First();
int rowCount = 0;
rowCount = ws.Dimension.End.Row;
for (int r = 2; r <= rowCount; r++)
{
string status = ws.Cells[r, 11].Value?.ToString();
string deliveredDate = ws.Cells[r, 15].Value?.ToString();
string deliveredTime = ws.Cells[r, 17].Value?.ToString();
}
fs.Close();
}
}