ODBC xlsx driver connectionstring without header

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 08:56:06

问题


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"

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.

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.

Can somebody help me with that?

Thanks!


回答1:


I did some research.

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"

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

So if you set FirstRowHasNames=00 the first line wont be skipped.

Source



来源:https://stackoverflow.com/questions/49506048/odbc-xlsx-driver-connectionstring-without-header

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