处理Excel 2007列标题中的点(。)字符 [英] Handling Dot (.) character in Excel 2007 Column Headers
问题描述
我们正在研究使用OLEDB连接在ASP.NET中查询Excel 2007文件的要求。我们能够在查询时执行所有所需的操作,但在Excel工作表列名称包含Dot(。)字符时面临问题。
代码如下:
使用(OleDbCommand cmd = new OleDbCommand(Select *,[ Prd.Inv Line Item]+ UserId +as [USerID] from [Sheet1 $],excelConnection))
我们收到以下错误
无效的名称包围''[Prd。 Inv Line Item]''。
等待你的回应...
Hi,
We are working on a requirement where we are querying Excel 2007 file in ASP.NET using OLEDB connection. We are able to perform all the desired operations while querying, but facing problem when Excel sheet column name contain Dot (.) character.
The code is given below
using (OleDbCommand cmd = new OleDbCommand("Select *,[Prd. Inv Line Item]" + UserId + " as [USerID] from [Sheet1$] ", excelConnection))
We are getting the following error
Invalid bracketing of name ''[Prd. Inv Line Item]''.
Waiting for your reponse...
推荐答案
,excelConnection ))
我们收到以下错误
无效包围名称''[Prd.Inv行项目'''。
等待你的回应...
", excelConnection))
We are getting the following error
Invalid bracketing of name ''[Prd. Inv Line Item]''.
Waiting for your reponse...
当我更换支架并检查
使用(OleDbCommand cmd = new OleDbCommand(Select *,Prd.Inv Line Item,+ UserId +as [USerID] from [Sheet1
When i replace bracket and checked
using (OleDbCommand cmd = new OleDbCommand("Select *,Prd. Inv Line Item," + UserId + " as [USerID] from [Sheet1
]
,excelConnection))
但错误为查询表达式中的语法错误(缺少运算符)Prd。 Inv Line Item''。
", excelConnection))
but getting the error as "Syntax error (missing operator) in query expression ''Prd. Inv Line Item''."
这篇关于处理Excel 2007列标题中的点(。)字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!