日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

Excel導出。PageControl - Delphi / VCL組件開發(fā)及應用

 wangsongliang 2011-01-03
procedure TRES_DCC_ECRN_F.cxButton1Click(Sender: TObject);
var
  ExcelApp,WorkBook:Olevariant;
  ExcelSheetCount,i,k:Integer;
begin
  inherited;
 
if RzButtonEdit1.Text <>'' then
 
begin
   
if (ExtractFileExt(RzButtonEdit1.Text)<>'.xls')   then
   
begin
      MessageDlg(
'請選擇要導入的Excel檔案!',mtWarning,[mbOK],0);
      RzButtonEdit1.Clear;
   
end
   
else
   
begin try Application.ProcessMessages; ExcelApp:=CreateOleObject('Excel.Application');
        WorkBook:
=ExcelApp.WorkBooks.Open(RzButtonEdit1.Text);
        ExcelApp.Visible:
=False;
        ExcelSheetCount:
=WorkBook.WorkSheets.Count;
       
for i:=1 to ExcelSheetCount  do
       
begin
          Screen.Cursor:
=crSQLWait;
          WorkBook.WorkSheets[i].Activate;
          a:
=ExcelApp.Cells[4,2].Value;
          b:
=ExcelApp.Cells[8,2].Value;
          c:
=ExcelApp.Cells[14,2].Value;
          d:
=ExcelApp.Cells[21,2].Value;
          e:
=ExcelApp.Cells[22,2].Value;
          f:
=ExcelApp.Cells[23,2].Value;
         
if ((Copy(Trim(a),1,3)<>'ECR') and (b<>'')) and ((Copy(Trim(a),1,3)<>'DCR') and (b<>'')) then
         
begin
            MessageDlg(
'檔案格式錯誤!',mtWarning,[mbOK],0);
            InsertErrorLOG;
            Screen.Cursor:
=crDefault;
            Exit;
         
end;

         
with adoq_ecrn do
         
begin
            Close;
            SQL.Text:
='select * from RES_ECR_TYPE where ECRNO='''+ a+'''';
            Open;
           
if RecordCount=1 then
           
begin
              MessageDlg(
'請檢查:導入檔案時編號"'+ a+'"的記錄重復!',mtWarning,[mbOK],0);
              InsertRepeatLOG;
              Screen.Cursor:
=crDefault;
              Exit;
           
end;
         
end;

          
with adoq_ecrn do
          
begin
             Close;
             SQL.Clear;
             SQL.Add(
'insert into RES_ECR_TYPE(ECRNO,DESOFCHANGE,RELEASEDATE,RESPEOPLE,ISSUEDEPT,MODEL) values(:a,:b,:c,:d,:e,:f)');
             Parameters.ParamByName(
'a').Value:=a;
             Parameters.ParamByName(
'b').Value:=b;
             Parameters.ParamByName(
'c').Value:=Trim(Copy(c,1,19));
             Parameters.ParamByName(
'd').Value:=d;
             Parameters.ParamByName(
'e').Value:=e;
             Parameters.ParamByName(
'f').Value:=f;
             ExecSQL;
          
end;
           InsertECRLOG;

           ProgressBar1.Min:
=0;
           ProgressBar1.Max:
=ExcelSheetCount;
          
for k:=33 to WorkBook.WorkSheets[i].usedrange.rows.count  do
          
begin
             g:
=ExcelApp.Cells[K,1].Value;
             q:
=ExcelApp.Cells[k,2].Value;
             w:
=ExcelApp.Cells[k,3].Value;
             v:
=ExcelApp.Cells[k,4].Value;
             r:
=ExcelApp.Cells[k,5].Value;
             t:
=ExcelApp.Cells[k,6].Value;
             y:
=ExcelApp.Cells[k,7].Value;
             u:
=ExcelApp.Cells[k,8].Value;
             o:
=ExcelApp.Cells[k,9].Value;
            
if (q<>'')and(w<>'') then
            
with adoq_item do
            
begin
               Close;
               SQL.Clear;
               SQL.Add(
'insert into RES_ECR_ITEM(GROUPID,ECRNO,ITEMNO,ITEMDESPTION,FZRELATION,CHANGETYPE,BEFORECHANGE,AFTERCHANGE,PROPOSE,REMARK) values(:g,:p,:q,:w,:v,:r,:t,:y,:u,:o)');
               Parameters.ParamByName(
'g').Value:=g;
               Parameters.ParamByName(
'p').Value:=a;
               Parameters.ParamByName(
'q').Value:=q;
               Parameters.ParamByName(
'w').Value:=w;
               Parameters.ParamByName(
'v').Value:=v;
               Parameters.ParamByName(
'r').Value:=r;
               Parameters.ParamByName(
't').Value:=t;
               Parameters.ParamByName(
'y').Value:=y;
               Parameters.ParamByName(
'u').Value:=u;
               Parameters.ParamByName(
'o').Value:=o;
               ExecSQL;
               ProgressBar1.Position:
=ProgressBar1.Position+1;
            
end;
          
end;
           Screen.Cursor:
=crDefault;
           Application.ProcessMessages;
           ProgressBar1.Position:
=0;
           RefreshECRN;
           RefreshGroupItem;
           SendToEmail;
           Zt:
=1;
        
end;
      finally
        ExcelApp.ActiveWorkBook.Saved:
=True;
        WorkBook.Close;
        ExcelApp.Quit;
     
end;
    
end;
 
end
 
else
 
begin
    MessageDlg(
'請選擇要導入的Excel檔案!',mtWarning,[mbOK],0);
    Exit;
 
end;
end;

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多