螺纹钢历史价格走势图:急!!excel导入paradox程序调试错误!

来源:百度文库 编辑:神马品牌网 时间:2024/04/24 06:23:19
project project1.exe raised exception class EDBEngineError with message 'Table doees not exist.
file or directory dose not exist.
file:E:\delphi\excel\试验.DB
file:E:\delphi\excel\试验.dbf
file:E:\delphi\excel\试验.txt
file:cE:\\delphi\excel\试验'.Process stopped.Use Step or run to continue.
代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var i,j,n:integer;
temp:string;
begin
opendialog1.InitialDir:=ExtractFileDir(paramstr(0));//文件的打存放初始路径
opendialog1.Execute;
Try
ExcelApplication1.Connect;//EXCEL应用程序
Except
MessageDlg('Excel may not be installed',mtError, [mbOk], 0);
Abort;
End;
ExcelApplication1.Visible[0]:=true;
ExcelApplication1.Caption:='Excel Application';
try
excelapplication1.Workbooks.Open(opendialog1.FileName,
null,null,null,null,null,null,null,null,null,null,null,null,0);//打开指定的EXCEL 文件
except
begin
ExcelApplication1.Disconnect;//出现异常情况时关闭
ExcelApplication1.Quit;showmessage('请选择EXCEL电子表格!');
exit;
end;
end;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);//ExcelWorkbook1与Eexcelapplication1建立连接
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);//Excelworksheet1与Excelworkbook1建立连接
for i:=2 to 100 do
begin
if trim(excelworksheet1.cells.item[i,1])<>'' then
begin
qr1.Close;
qr1.params.clear;
qr1.SQL.clear;
qr1.Params.CreateParam(ftstring,'xh',ptinput).asstring:=trim(excelworksheet1.cells.item[i,1]);
qr1.sql.text:='select * from 试验 where xh=:xh';
qr1.execsql;
qr1.Open;
n:=qr1.recordcount;
if n=0 then
begin
Table1.Append;
for j := 1 to 11 do
begin
temp :=excelworksheet1.cells.item[i,j];
Table1.Fields[j - 1].AsString := temp;
end;
table1.post;//加上这句::::)))))
end;
end;
end;
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
end;

end.

在ACCESS中打开某个数据库
单击菜单 文件-获取外部数据-导入,在对话框中选择要用的EXCEL文件
按照向导提示执行就行了,可以放在新表中,也可以放在已有的表中。

但是要注意,最好是在EXCEL中为使用的数据作个命名区域,还有EXCEL中的数据一定要规规矩矩,第一行是列标题,下面各行是数据,标题和数据不要跨列,不要有合并的单元格,否则可能不行。