Getting “Invalid bracketing of name” error when i try to run query on excel sheet

99封情书 提交于 2020-02-02 02:26:06

问题


In order to make some reports I need to parse some excel files. When I try to select records from sheet I get next error: Invalid bracketing of name '1. page$'.

Heres my code:

OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [1. page$]", connectionString);

I know it will work if I rename sheet to "page" for example, but as i'm not naming these sheets I need to know how to fix this query to work as it is. What should I do?


回答1:


I had this same problem, replaced the . with a # and it works. Thanks!




回答2:


It looks like your sheet name [1. page$] is invalid. This is OK for an Excel sheet name, but not OK in the query. You should not have the "." in your sheet name.

You can't get around the "." problem. It's just not valid when you are running the query.




回答3:


SpreadsheetGear for .NET will let you work with Excel files without the limitations imposed by OleDb.

You can see C# and VB samples here and try it yourself by downloading the free trial here.

Disclaimer: I own SpreadsheetGear LLC



来源:https://stackoverflow.com/questions/1178187/getting-invalid-bracketing-of-name-error-when-i-try-to-run-query-on-excel-shee

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