c# - Excel Reading Problem with Column having multiple types -
I am reading Excel file in the .Net Framework 1.1, using C #. I am having trouble reading excel file when I have a column in which there is a number, like some text
1003 1004 1005 Test_1 Test_2
This is not giving me any errors , But I get zero values in the first three lines. This is the code that I am using to read the excel file.
string strccon = "provider = Microsoft. Jt.oledb.4.0; data source =" + path + "; extended property = excel 8.0;"; System.Data.OleDb.OleDbConnection objConn = New system. Data.OleDb.OleDbConnection (stren); Try {objConn.Open (); System.Data.OleDb.OleDbDataAdapter objadp = new System.Data.OleDb.OleDbDataAdapter ( "select" [ "+ sheetName +" $ "+"] ", objConn); DataSet ds = new DataSet (); Objadp.Fill ( DS); return ds;} catch (exception ex) {ex} finally {ObjConnkClose (); ObjConnkDispose (in);} can someone tell me Thank you.
I have no .NET 1.1 installed on my machine , But was able to reproduce the problem with .NET 2.0 installed. C is modified and now I am able to read the text values.
string Strcon = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = "+ @" C: \ Documents and Settings \ johnsond \ Desktop \ Book1.xls "+ @"; Expanded Properties = "+ Convert. Tochar (34) .ostring () + @" Excel 8.0; Imex = 1; HDR = Yes; "+ Knhwartkkocr (34) Kostring (); Quote of Microsoft forums to find the cause of the problem:
You have a problem very common is, because Excel is not the actual database and data type column is not certain jet OLEDB was unwilling to work with, especially Excel and those limitations.
I do not know Very solid :-) Also if you want to write such data to excel Further, it becomes more complex. Further reading:
Alternatively you can use "Excel.Application Object" to manipulate sheets. Strong>, as is already discoussed.
Check if you want:
Cheers!
Comments
Post a Comment