Delphi_Excel例子:单元格拷贝粘贴
2006-02-04 13:41:59 来源:WEB开发网核心提示://Excel的单元格拷贝粘贴PRocedure Excel_copyCells;var sheet,XLApp,workbook,myRange1 ,myRange2: variant;begin try //创建对象 XLApp:=createOleObject('Excel.application
//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;
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;
更多精彩
赞助商链接