不含标头的ODBC xlsx驱动程序连接字符串 [英] ODBC xlsx driver connectionstring without header
问题描述
我正在使用以下命令通过 ODBC 连接到 xlsx 文件:
I am connecting to xlsx files via ODBC with following command:
"DRIVER=Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb);HDR=YES;IMEX=1;READONLY=TRUE;DBQ=C:\Temp\test.xlsx"
它工作正常,但是当文件中没有标题时,我总是会丢失一行. 显然是因为参数"HDR = YES" ,但是我无法弄清楚如何禁用标题行.
It works fine but I am always missing one line when there is no header in the file. Obviously it's because of the parameter "HDR=YES" but I cant figure out how to disable the header line.
我尝试了"HDR = NO" ,并且将此参数保留了下来 但没有效果. 我可以访问该文件,但总是丢失第一行.
I have tried "HDR=NO" and leaving this parameter out but no effect. I can access to the file but I always lose the first line.
有人可以帮我吗?
谢谢!
推荐答案
我做了一些研究.
如果通过类似的驱动程序打开 XLS 或 XLSX 文件,
If you open a XLS or XLSX file via a driver like
"DRIVER=Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb);HDR=YES;IMEX=1;READONLY=TRUE;DBQ=C:\Temp\test.xlsx"
驱动程序完全忽略了参数. 因此"HDR = NO" 不起作用.
the driver is ignoring parameters completly. So "HDR=NO" has no effect.
显然,驱动程序使用注册表中的设置来确定第一行是否应解释为标题行.
Apparently the driver uses a setting in the registry to determine if the first line should be interpreted as an header line.
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\Access Connectivity Engine\Engines\Excel
因此,如果您设置 FirstRowHasNames = 00 ,第一行将不会被跳过.
So if you set FirstRowHasNames=00 the first line wont be skipped.
这篇关于不含标头的ODBC xlsx驱动程序连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!