Excel使用$返回sheetname

我使用ADO和下面的函数读取excel文件

procedure TForm1.ConnectToExcel; var strConn : widestring; begin strConn:='Provider=Microsoft.Jet.OLEDB.4.0;' + 'Data Source=' + Edit1.Text + ';' + 'Extended Properties=Excel 8.0;'; AdoConnection1.Connected:=False; AdoConnection1.ConnectionString:=strConn; try AdoConnection1.Open; AdoConnection1.GetTableNames(ComboBox1.Items,True); except ShowMessage('Unable to connect to Excel, make sure the workbook ' + Edit1.Text + ' exist!'); raise; end; end;(*ConnectToExcel*) procedure TForm1.FetchData; begin StatusBar1.SimpleText:=''; if not AdoConnection1.Connected then ConnectToExcel; AdoQuery1.Close; AdoQuery1.SQL.Text:='select * from' + SheetName; try AdoQuery1.Open; except ShowMessage('Unable to read data from Excel, make sure the query ' + SheetName + ' is meaningful!'); raise; end; end; 

对于几个excel文件这个代码工作得很好,但现在我尝试打开一个新的奇怪的错误。

在excel文件中,工作表名称是MYLIST,如果我检索工作表名称列表,我将名称MYLIST $返回。 即使使用MYLIST或MYLIST $,我也无法打开此工作表。 可能是什么问题。

Microsoft Jet引擎不允许在标识符中使用“$”符号,仅在内置函数中使用。 如果您在名称中使用此符号,则应引用这些标识符。
所以试试这个:

 select * from [MYLIST$]