delphi里怎么把excel导入access?
如题
[解决办法]
如果只是想把Excel中的数据导入到Access中那很简单, 不用delphi写代码都行,
Access中数据导入功能的. 如果想用delphi 去控制, 就得能 Excel与Access的COM
接口去做.
[解决办法]
var
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;
[解决办法]
http://www.torry.net/pages.php?id=555
看看有没有适合你的
[解决办法]
学习!
[解决办法]
up
[解决办法]
http://community.csdn.net/Expert/TopicView.asp?id=5584664
[解决办法]
兄弟,用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;