var ADO_ConnectionString:string;
ADOQuery_ConnectionString:string; sheet,strsql:string;
begin if OpenDialog_Excel.Execute then
begin
Edit_Excel_DataSource.Text :=OpenDialog_Excel.FileName ;
ADO_Connectionstring:=''Provider=Microsoft.Jet.OLEDB.4.0;''+
''Data Source=''+
Edit_Excel_DataSource.Text+
'';Mode=ReadWrite|Share Deny None;''+
''Extended Properties=Excel 8.0;Persist Security Info=False'';
ADOConnection_Excel.ConnectionString :=ADO_Connectionstring;
ADOConnection_Excel.Connected :=true;
ADOConnection_Excel.GetTableNames(ListBox_SheetList.Items,false);
for sheet_count:=0 to ListBox_SheetList.Items.Count-1 do
begin
sheet:=ListBox_SheetList.Items.Strings[sheet_count];
ADOQuery_ConnectionString:=''Provider=Microsoft.Jet.OLEDB.4.0;''+
''Data Source=''+
Edit_Excel_DataSource.Text+
'';Extended Properties=Excel 8.0;Persist Security Info=False'';
ADOQuery_Excel.ConnectionString :=ADOQuery_ConnectionString;
strsql := ''select * from [''+Sheet+''$]'' ;
strsql := strsql + '' where id = '''''' + Edit_IDNO.Text '''''''';
//
ADOQuery_Excel.SQL.active := false;
ADOQuery_Excel.SQL.Clear ;
ADOQuery_Excel.SQL.Add(strsql);
ADOQuery_Excel.SQL.Active :=true;
//
if ADOQuery_Excel.RecordCount > 0 then
begin
label1.Caption :=ADOQuery_Excel.FieldByName(''name'').Asstring;
end;
end;
end;