incorrect date format representation
See original GitHub issueI working on excel date retrieving using ExcelDataReader. but it seem that i find issue with date column.
below is the image of excel data:
On retrieving using ExcelDataReader the date format is representing in number.
My code is :
using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
{
string fileExe = Path.GetExtension(FileUpload1.PostedFile.FileName);
IExcelDataReader excelReader;
if (fileExe == ".xls")
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
{
excelReader = ExcelReaderFactory.CreateBinaryReader(stream, true);
//var excelReader = Excel.ExcelReaderFactory.CreateBinaryReader(inputStream, true);
}//...
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
else
{
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
}
var excelDataSet = excelReader.AsDataSet(true);
//5. Data Reader methods
int j = 0;
while (excelReader.Read())
{
object[] array = new object[excelReader.FieldCount];
for (int i = 0; i < excelReader.FieldCount; i++)
{
if (j == 0)
{
dt.Columns.Add(i.ToString());
}
array[i] = excelReader.GetString(i);
}
j++;
dt.Rows.Add(array);
}
//6. Free resources (IExcelDataReader is IDisposable)
excelReader.Close();
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Convert an Incorrect Date Format into a Real Date in Excel
Change an incorrectly formatted/input date into the proper date format for Excel. This tutorial is specific to when someone inputs a "short" date...
Read more >How to Fix Excel Dates That Won't Change Format
How to fix Excel dates that will not change format. Fix dates that end up in the wrong order when sorted. Use built-in...
Read more >Java SimpleDateFormat.format() returns incorrect date ...
Even "yyyy-MM-dd'T'kk:mm:ss.SSS" returns incorrect values. Edit2 : I am using this code in Android App. It works on perfectly on emulator(API 23) ...
Read more >Incorrect Date format
I would prefer the date in format (date) (month) (year) for eg. 15 August 2022. The month to always be alphabets and not...
Read more >Excel Integration incorrect date format
I've never had issues integrating into excel, but I now the date format is coming in like this and I can't figure out...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Passing ‘true’ to the excelReader.AsDataSet method resolved the Date format issue for .xls files (into Dataset) . DataSet result = excelReader.AsDataSet(true);
Looks like the dates are rendered as double because ConvertOaDates = false.