Mixed Data Type in Excel, IMEX Doesn't Work

岁酱吖の 提交于 2019-11-30 16:18:44

问题


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.


回答1:


Are you sure that TypeGuessRows=0; and ImportMixedTypes=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, but TypeGuessRows=8, and should be set to 0 as in your connection string.



来源:https://stackoverflow.com/questions/9918279/mixed-data-type-in-excel-imex-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!