



























Microsoft Jet 提供程序用于连接到 Excel 工作簿。在以下连接字符串中,Extended Properties 关键
字设置 Excel 特定的属性。“HDR=Yes;”指示第一行中包含列名,而不是数据,“IMEX=1;”通知驱动程
序始终将“互混”数据列作为文本读取。注意
http://msdn2.microsoft.com/zh-cn/library/ms254978.aspx
默认情况下,系统认为 Excel 数据源的第一行包含可用作字段名的列标题。如果不是这种情况,则必须
将该设置关闭,否则,第一行数据将会“消失”,而被用作字段名称。这可通过向连接字符串的扩展属性
添加可选的 HDR= 设置来完成。默认情况下(无需指定)是 HDR=Yes。如果没有列标题,则需要指定
HDR=No;提供程序将字段命名为 F1、F2 等等。因为扩展属性字符串现在包含了多个值,所以必须用引号
单独包起来,如下例所示(为便于看清楚,添加了额外的空格)。
如第1个中hdr=no的话,where时就会报错
ConnStr ="Driver={Microsoft Excel Driver (*.xls)};Dbq=C:\Inetpub\wwwroot\test.xls;
Extended Properties='Excel 8.0;HDR=No;IMEX=1'"
Extended Properties参数属性这样写 Excel 5.0;HDR=YES;IMEX=1
IMEX=1就是指混合型转换为文本
select * from
OPENROWSET(’MICROSOFT.JET.OLEDB.4.0′
,’Excel 5.0;HDR=YES;IMEX=2;DATABASE=c:\book1.xls’,[sheet1$])
1)hdr=yes时可以把xls的第1行作为字段看待,如第1个中hdr=no的话,where时就会报错
2)[]和美圆$必须要,否则M$可不认这个账