I am reading excel sheet using ADO DB in C# but the problem I am facing is it is not able to copy the cell data with its format. For e.g.
One of my cell is in Currency format ($2,123.45) so when I am getting the result set I am getting the cell value as (2123.45).
Is there any way I can get exactly same cell data as it is displayed in excel sheet. Below is my code for getting the result set from excel
string sQuery = "Select * From [" + sSheet + "$]";
if (dtType == DataLayer.TestData)
sWorkbook = Path.GetDirectoryName(ConfigurationManager.AppSettings["resourcesFolder"]) + @"\Data\Test Data\" + sWorkbook;
if (dtType == DataLayer.ExpectedData)
sWorkbook = Path.GetDirectoryName(ConfigurationManager.AppSettings["resourcesFolder"]) + @"\Data\Expected Data\" + sWorkbook;
string cnStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sWorkbook + "; Extended Properties= 'Excel 8.0; HDR=Yes; IMEX=1'";
oConn.Open(cnStr, null, null, 0);
oRS.Open(sQuery, cnStr, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1);
oConn.Close();
Please do provide some solution to the same.
Note : worst case scenario I can go for other options for reading Excel if my performance is not hampered.