I have tried to import the excel the date column in excel is changing to number format. For example I have 3 column in the excel Name,age and Dob
When I try to convert this excel into the datatable the date in the Dob column is changing to a number.
using (ExcelPackage excelPackage = new ExcelPackage(fi))
{
ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[sheetName];
ExcelCellAddress startCell = worksheet.Dimension.Start;
ExcelCellAddress endCell = worksheet.Dimension.End;
if (endCell.Row > 0)
{
for (int col = startCell.Column; col <= endCell.Column; col++)
{
dt.Columns.Add(Convert.ToString(worksheet.Cells[startCell.Row, col].Value));
}
for (int row = startCell.Row + 1; row <= endCell.Row; row++)
{
DataRow dr = dt.NewRow();
int x = 0;
for (int col = startCell.Column; col <= endCell.Column; col++)enter code here
{
dr[x++] = worksheet.Cells[row, col].Value;
}
dt.Rows.Add(dr);
}
}
}