Excel数据导入遭遇到了一个问题,从Excel导入的数据中有部分数据丢失。如下图所示,ZIP字段明明设置了是文本格式,但是导入到数据库中去时似乎因为存在格式问题二导致部分数据导入为空,大致是混合字段的格式问题,如何解决?只需要在Excel to Dataset的时候,加一个IMEX=1的字符串,如下图所示,含义是“IMEX = 1; 告诉系统如一个列中有数字和文本 就是“混合”数据列, 那么都作为文本来对待”,OK,这样导入就能正常导入了。

另外一个参数HDR=Yes; 告诉系统表示第一行包含columnnames,而不是数据。

You need to use IMEX attribute, If your excel is 2003, then excel library version is 11.0, but 8.0 should also be fine. Try the below things


Extended Properties='Excel 8.0;IMEX=1'; The single quotes should start after = and end after 1. If this does not work try the below

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""

"HDR=Yes;" indicates that the first row contains columnnames, not data.
"IMEX=1;" tells the driver to always read "intermixed" data columns as text



原文链接地址:http://www.mockte.com/rewrite.php/read-394.html