procedure TForm1.Button1Click(Sender: TObject);
var
exceltem:variant;
excelnew:variant;begin
exceltem:=createoleobject('excel.application');
excelnew:=createoleobject('excel.application');
excelnew.visible:=true;
exceltem.workbooks.open('F:\exceltest\template\111.xls');
excelnew.workbooks.add;
exceltem.worksheets[1].activate;
excelnew.worksheets[1].activate;
excelnew.cells[1,1].value:=exceltem.cells[1,1].value;
excelnew.cells[1,2].value:=exceltem.cells[1,2].value;
excelnew.cells[1,3].value:=edit1.Text; Excelnew.ActiveWorkBook.SaveAs('f:\exceltest\new1.xls');
showmessage('success');
excelnew.workbooks.close;
exceltem.workbooks.close;
excelnew.quit;
exceltem.quit;
excelnew:=unassigned;
exceltem:=unassigned;
end;
结束后,任务管理器里任然有excel进程
var
exceltem:variant;
excelnew:variant;begin
exceltem:=createoleobject('excel.application');
excelnew:=createoleobject('excel.application');
excelnew.visible:=true;
exceltem.workbooks.open('F:\exceltest\template\111.xls');
excelnew.workbooks.add;
exceltem.worksheets[1].activate;
excelnew.worksheets[1].activate;
excelnew.cells[1,1].value:=exceltem.cells[1,1].value;
excelnew.cells[1,2].value:=exceltem.cells[1,2].value;
excelnew.cells[1,3].value:=edit1.Text; Excelnew.ActiveWorkBook.SaveAs('f:\exceltest\new1.xls');
showmessage('success');
excelnew.workbooks.close;
exceltem.workbooks.close;
excelnew.quit;
exceltem.quit;
excelnew:=unassigned;
exceltem:=unassigned;
end;
结束后,任务管理器里任然有excel进程
hoho