读取带有字符的Excel工作表名称 [英] Reading Excel sheet name with characters
问题描述
你好,
我有一个工作表名称为"Test-Sheet!"的Excel文件.从我将数据导入到sql表的位置.
我为此使用Excel Oledb.
字符串firstSheetName =测试表!"
OleDbAdapter oleAdapter =新的OleDbAdapter("SELECT * FROM [" + firstSheetName +"$]",dbConnection);
我收到错误消息,说:"[Test-Sheet!$]不是有效名称.请确保它不包含无效字符或标点符号,并且名称不要太长"
谁能建议解决这个问题的方法?
谢谢
Hello,
I have a Excel file with sheetname, "Test- Sheet!" from where I am importing data to a sql table.
I am using Excel Oledb for this.
string firstSheetName = "Test- Sheet!"
OleDbAdapter oleAdapter = new OleDbAdapter ("SELECT * FROM [" + firstSheetName + "$]", dbConnection);
I am getting error saying, "[Test- Sheet!$] is NOT a VALID Name. Make sure that it does not include Invalid characters or punctuation and that it is not too long"
Can anyone suggest a solution to this issue?
Thanks
推荐答案
,dbConnection);
我收到错误消息,说:"[测试表!
", dbConnection);
I am getting error saying, "[Test- Sheet!
不是有效名称.请确保该名称不包含无效字符或标点符号,并且名称不要太长"
谁能建议解决这个问题的方法?
谢谢
is NOT a VALID Name. Make sure that it does not include Invalid characters or punctuation and that it is not too long"
Can anyone suggest a solution to this issue?
Thanks
尝试在连接字符串中使用IMEX.
有关详细信息,请参见下面的链接:
http://www.connectionstrings.com/excel [
Try using IMEX in Connection String.
See below link for details:
http://www.connectionstrings.com/excel[^]
这篇关于读取带有字符的Excel工作表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!