I am trying to export xls into datatable. Below is my connection string.
string path = //xls source path
OleDbConnection MyConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + path + "';Extended Properties='Excel8.0;IMEX=1;TypeGuessRows=0;HDR=No;ImportMixedTypes=Text'");
I set IMEX=1
and all the other extended properties as I have to deal with mixed datatypes.
Even though I set the connection like that yet I still produced error.
There are no error messages, but the inconsistent rows (who don't follow the majority datatype are set to null instead).
Can someone tell me what did I miss? Btw, I am using the OleDbDataAdapter
& Fill(DataSet)
method.
Are you sure that
TypeGuessRows=0;
andImportMixedTypes=Text;
are working from connection string and should not be modified in registry (HKEY_LOCAL_MACHINE\SOFTWARE\[Wow6432Node\]Microsoft\Jet\4.0\Engines\Excel
)? AFAIK this settings are read from registry.ImportMixedTypes=Text
is usually by default, butTypeGuessRows=8
, and should be set to0
as in your connection string.