简体   繁体   English

读取Excel工作表时出错-工作表名称中的特殊字符

[英]Error while reading excel sheet - special character in sheet name

I am reading data from excel sheet using excel oledb with C#. 我正在使用带有C#的excel oledb从excel工作表中读取数据。

Query is below : 查询如下:

"SELECT * FROM [Test$A6:IU6]"

Its working perfectly. 它的工作完美。 But if I give the sheet name "Test+" then I am getting error. 但是,如果我给工作表名称“ Test +”,那么我会出错。

Query is below: 查询如下:

"SELECT * FROM [Test+$A6:IU6]"

The error I am getting: 我得到的错误:

"The Microsoft Jet database engine could not find the object 'Test+$A6:IU6'. Make sure the object exists and that you spell its name and the path name correctly." “ Microsoft Jet数据库引擎找不到对象'Test + $ A6:IU6'。请确保该对象存在,并且正确拼写了其名称和路径名。”

Is there any way by which I can read the data from excel sheet which has special char in sheet name ? 有什么办法可以从工作表名称中包含特殊字符的excel工作表中读取数据?

One option would be to read in all the worksheets then extract the names they do have. 一种选择是阅读所有工作表,然后提取它们确实拥有的名称。 This will give you an indication of what the name above is known as internally when the special characters are included and you can adjust for that. 当包含特殊字符时,这将为您指示上面的名称在内部的含义,您可以对此进行调整。

See http://social.msdn.microsoft.com/Forums/vstudio/en-US/ce4bbe9c-7d13-44c5-a26c-4b84912a51f3/read-excel-file-without-worksheet-name?forum=vbgeneral 请参阅http://social.msdn.microsoft.com/Forums/vstudio/en-US/ce4bbe9c-7d13-44c5-a26c-4b84912a51f3/read-excel-file-without-worksheet-name?forum=vbgeneral

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM