var ExcelApp,ExcelApp2: Variant;
begin
  ExcelApp := CreateOleObject( 'Excel.Application' );
  //ExcelApp.Visible := True;
  ExcelApp.WorkBooks.Open( 'C:\Documents and Settings\Administrator\桌面\File1.xls' );
  ExcelApp.WorkBooks.Open( 'C:\Documents and Settings\Administrator\桌面\File2.xls' );
  ExcelApp.workbooks[1].WorkSheets[1].Range[ 'A1:I20' ].Copy;
  ExcelApp.WorkBooks[2].worksheets.add;
  ExcelApp.WorkBooks[2].worksheets[1].Range['A1'].PasteSpecial;
  ExcelApp.WorkBooks[2].WorkSheets[1].Name:='test1';
  ExcelApp.WorkBooks[2].WorkSheets[2].Name:='test2';
  ExcelApp.workbooks[2].save;
  ExcelApp.ActiveWorkBook.Saved := True;

  ExcelApp.WorkBooks.Close;
  ExcelApp.quit;

end;

把多个excel 的内容复制到一个EXCEL中

posted on 2011-06-23 17:29  jing_lee  阅读(1814)  评论(0编辑  收藏  举报