兄弟,用ADO方式,快捷,方便(要求格式要規范) procedure TForm1.sbPlacementSearchClick(Sender: TObject); begin if OpenDialog1.Execute then Edit1.Text:=OpenDialog1.FileName; ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0 ' +';Data Source='+Edit1.Text +';Extended Properties=Excel 8.0 ' +';Persist Security Info=False '; ADOConnection1.LoginPrompt:=False;
end;procedure TForm1.Button1Click(Sender: TObject); begin with ADOQuery1 do begin SQL.Clear; SQL.text:='Select * from [MC1$] in ' +'"'+Edit1.Text +'" "Excel 8.0;hdr=yes;imex=1"'; Open; end;end;
兄弟,用ADO方式,快捷,方便(要求格式要規范) procedure TForm1.sbPlacementSearchClick(Sender: TObject); begin if OpenDialog1.Execute then Edit1.Text:=OpenDialog1.FileName; ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0 ' +';Data Source='+Edit1.Text +';Extended Properties=Excel 8.0 ' +';Persist Security Info=False '; ADOConnection1.LoginPrompt:=False;
end;procedure TForm1.Button1Click(Sender: TObject); begin with ADOQuery1 do begin SQL.Clear; SQL.text:='Select * from [MC1$] in ' +'"'+Edit1.Text +'" "Excel 8.0;hdr=yes;imex=1"'; Open; end;end;
i, j: integer;
begin Try
ExcelApplication.Connect;
Except
Abort;
End;
try
ExcelApplication.Workbooks.Open(FilePath,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0);
except
ExcelApplication.Disconnect;
ExcelApplication.Quit;
Exit;
end; ExcelWorkBook.ConnectTo(ExcelApplication.Workbooks[1]);
ExcelWorkSheet.ConnectTo(ExcelWorkBook.Worksheets[1] as _Worksheet); ExcelWorkSheet.Cells.item[i,j];//这就是你要读的数据 循环读取就可以了,自己改一下。把读取来的数据存到Access就不要说了吧。
ExcelApplication.Disconnect;
ExcelApplication.Quit;
procedure TForm1.sbPlacementSearchClick(Sender: TObject);
begin
if OpenDialog1.Execute then
Edit1.Text:=OpenDialog1.FileName; ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0 '
+';Data Source='+Edit1.Text
+';Extended Properties=Excel 8.0 '
+';Persist Security Info=False '; ADOConnection1.LoginPrompt:=False;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
with ADOQuery1 do
begin
SQL.Clear;
SQL.text:='Select * from [MC1$] in '
+'"'+Edit1.Text +'" "Excel 8.0;hdr=yes;imex=1"';
Open;
end;end;
procedure TForm1.sbPlacementSearchClick(Sender: TObject);
begin
if OpenDialog1.Execute then
Edit1.Text:=OpenDialog1.FileName; ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0 '
+';Data Source='+Edit1.Text
+';Extended Properties=Excel 8.0 '
+';Persist Security Info=False '; ADOConnection1.LoginPrompt:=False;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
with ADOQuery1 do
begin
SQL.Clear;
SQL.text:='Select * from [MC1$] in '
+'"'+Edit1.Text +'" "Excel 8.0;hdr=yes;imex=1"';
Open;
end;end;