|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
excel数据为:
以下代码读取时,没有update到2017-09-10数据,后面还有2017-09-11 2017-09-12 等数据
var
iRE:Integer;
iRow,iCol :Integer;
MsExcel,MsExcelWorkBook,MsExcelWorkSheet:Variant;
i:Integer;
eicol:Integer;
eirow:Integer;
begin
Try
OpenDialog1.FileName:='*.xls';
if not OpenDialog1.Execute then
begin
Exit;
end;
if ExtractFileExt(OpenDialog1.FileName) <> '.xls' then
begin
MessageBox(0, '请选择正确的excel文件',PChar('提示'),MB_OK or MB_ICONWARNING);
Exit;
end;
MsExcel:=CreateOleObject('Excel.Application');
MsExcel.visible:=true;
MsExcelWorkBook:=MsExcel.WorkBooks.Open(OpenDialog1.FileName);
Application.ProcessMessages;//防止进程阻塞
iRow:=2;
iCol:=1;
i:=1;
while trim(msExcel.WorkSheets['sheet1'].Cells[iCol,eicol].value) <> '' do begin
with query.Close;
query.SQL.Text := 'update wh_dict set wh_amount=:wh_ amount where wh_id= :wh_id and wh_name:=wh_name and in_date:=in_date ;
Parameters.ParamByName('wh_id').Value := Trim(msExcel.WorkSheets[1].Cells[iRow,iCol].value);
Parameters.ParamByName('wh_name').Value := Trim(msExcel.WorkSheets[1].Cells[iRow,iCol+1].value);
Parameters.ParamByName(' wh_amount').Value := Trim(msExcel.WorkSheets[1].Cells[iRow,iCol+2].value);
Parameters.ParamByName('duty_date').Value := Trim(msExcel.WorkSheets[1].Cells[i,iCol+2].value);
ExecSQL;
end;
iRow:=iRow+1;
end;
MsExcel.Quit;
Except
MessageBox(self.Handle,'数据导入失败!','系统提示',0);
MsExcel.Quit;
Exit;
end ;
MessageBox(self.Handle,'数据导入成功!','系统提示',0);
end;
|
|