原创  Delphi_Excel例子:单元格拷贝粘贴 收藏

//Excel的单元格拷贝粘贴
procedure Excel_copyCells;
var
  sheet,XLApp,workbook,myRange1 ,myRange2: variant;
begin
  try
    //创建对象
    XLApp:=createOleObject('Excel.Application');
      XLApp.displayAlerts:=true;
      XLApp.ScreenUpdating:=true;
    XLApp.visible:=true;
    XLApp.WorkBooks.Add('D:\Test.xls');
    workbook := XLApp.workbooks[1];
    sheet:=workbook.worksheets[1];
    myRange1:=sheet.Range[sheet.cells[39,1],sheet.cells[79,16]];
    myRange2:=sheet.Range[sheet.cells[80,1],sheet.cells[120,16]];
    myRange1.Copy(myRange2) ;
  finally
    if not VarIsEmpty(XLApp) then begin
      XLApp.displayAlerts:=false;
      XLApp.ScreenUpdating:=true;
      XLApp.quit;
    end;
  end;
end;

发表于 @ 2004年09月08日 16:50:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:Delphi中Excel的快速导入 | 新一篇:活动目录的备份与恢复

  • 发表评论
  • 评论内容:
  •  
Copyright © TianGuanLeiOK
Powered by CSDN Blog