The code below works for this (sort of).
excelCon = new OleexcelCon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strFileName + ";Extended Properties=\"Excel 12.0;HDR=No;IMEX=1\";");
excelCon.Open();
strExcelSheetNames = GetSheetNames(excelCon);
for (int x = 0; x < strExcelSheetNames.Length; x++)
{
excelCmd.CommandText = "SELECT * FROM [" + strExcelSheetNames[x] + "]";
excelCmd.CommandType = CommandType.Text;
excelCmd.Connection = excelCon;
excelAdapter = new OleDbDataAdapter(excelCmd);
excelAdapter.Fill(dtExcelConvert);
}
I'm having an issue with the number columns however, if the number in the xlsx file is 612561120001 and it's displayed as 6.12561E+11 when i read it from the data table and convert it to a number it appears as 612561120000.
Here's an example of what i mean.



I have tried to convert the file to a csv file and read it in but they're comma's in a lot of the fields which cause issues when splitting the data.
Any help on this would be great.
Thanks
Amit ChoudharyPosted Mar 25, 2011, 8:14 AM
change the field type to Memo in excel and it'll hold your data in a large mount.
Thanks.
Sam HobbsPosted Mar 21, 2011, 7:59 PM
In other words you say "it appears as 612561120000" but it is not clear if the problem is only appearances or if the data actually is that value and you need it to not be that value.
VulpesPosted Mar 21, 2011, 5:22 PM
When you load it into the C# program I'd then parse it to a double and hopefully preserve the final digit.