var
FilePath,ic,fn,ZH0,ZH1:string;
ExlAPP,Sheet,Range:Variant;
Bname:string;
Ret,k,i:integer;
XLS:TXLSReadWriteII5;
begin
if RzTreeView1.Selected=nil then exit;
if RzTreeView1.Selected.Level<2 then
begin
showmessage('---请先选择具体项目!---');
exit;
end;
OpenDialog1.Filter:='excel文件(.xls)|.xls';
OpenDialog1.Execute();
if trim(OpenDialog1.FileName)='' then exit;
if not fileexists(OpenDialog1.FileName) then
begin
showmessage('所选文件【'+Opendialog1.FileName+'】不存在!');
exit;
end;
ZH0:=trim(RzTreeView1.Selected.Text);
FilePath:=Opendialog1.FileName;
XLS:=TXLSReadWriteII5.Create(nil);
XLS.Filename:=FilePath;
XLS.Read;
i:=StrToint(RzSpinEdit1.Text)-1;
K:=0;
while trim(XLS[0].asstring[2,i])<>'' do
begin
BName:=XLS[0].AsString[2,i];
RzLabel1.Caption:=' 正在导入:'+BName;
dm.Call_SP.Close;
dm.Call_SP.ProcedureName:='XSP_111CashBatIN';
dm.Call_SP.Parameters.Refresh;
dm.Call_SP.Parameters.ParamByName('@CID').Value:=dm.Auser.UserCID;
dm.Call_SP.Parameters.ParamByName('@INO').Value:=RzTreeView1.Selected.Text;
dm.Call_SP.Parameters.ParamByName('@Fcode').Value:=dm.Auser.Fcode;
dm.Call_SP.Parameters.ParamByName('@Adate').Value:=XLS[0].AsString[6,i];
dm.Call_SP.Parameters.ParamByName('@Adate0').Value:=XLS[0].AsString[7,i];
dm.Call_SP.Parameters.ParamByName('@Adate1').Value:=XLS[0].AsString[8,i];
dm.Call_SP.Parameters.ParamByName('@SName').Value:=XLS[0].AsString[1,i]+'--'+XLS[0].AsString[2,i];
dm.Call_SP.Parameters.ParamByName('@DName').Value:=XLS[0].AsString[3,i]+'--'+XLS[0].AsString[4,i];
dm.Call_SP.Parameters.ParamByName('@Tval').Value:=XLS[0].asstring[10,i];
dm.Call_SP.Parameters.ParamByName('@Note').Value:=XLS[0].asstring[11,i];
dm.Call_SP.Parameters.ParamByName('@BZ').Value:=XLS[0].asstring[9,i];
dm.Call_SP.Parameters.ParamByName('@Oper').Value:=dm.Auser.UserID+'--'+dm.Auser.UserName;
dm.Call_SP.ExecProc;
ret:=dm.Call_SP.Parameters.Items[0].Value;
dm.Call_SP.Close;
if ret<>0 then
begin
showmessage('---数据导入出错!('+BName+')['+IntTostr(ret)+']---');
inc(K);
end;
Inc(i);
end;
Screen.Cursor:=crDefault;
RzLabel1.Caption:=' 转换完毕!';
if K=0 then
BEGIN
showMEssage('---导入成功!---');
dm.QcxA.Close;
dm.QcxA.Open;
END else showmessage('---导入有错,请检查数据!---');
XLS.Free;
标签:dm,Parameters,--,SP,Value,XLSReadWriteII5,Call,XLS
From: https://www.cnblogs.com/abcoder-Robert/p/18068738