为什么我们在select查询中给出$符号?
(“select * from [Sheet1 $]”,connection);
我尝试在没有$符号的情况下检索数据,但显示错误。
所以任何人都会澄清我对Sheet1 $
中$的需求答案 0 :(得分:1)
ODBC和Ole DB的SQL语法略有不同
•For ODBC: SELECT "Column Name" FROM "Sheet One$". I.e. excel worksheet name followed by a "$" and wrapped in double quotes.
•For Ole DB: SELECT [Column Name] FROM [Sheet One$]. I.e. excel worksheet name followed by a "$" and wrapped in "[" "]" brackets.
Odbc连接字符串:
对于Excel 2.0-2003
DRIVER={Microsoft Excel Driver (*.xls)};IMEX=1;MaxScanRows=16;DBQ=C:\Invoice.xls;
对于Excel 2007
DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};IMEX=1;MaxScanRows=16;DBQ=C:\Invoice.xls;
高级ETL处理器和Visual Import ETL都使用odbc连接到Excel
OLE DB连接字符串:
对于Excel 2.0-2003
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";
对于Excel 2007
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";