如下所示:
procedure TRPQMForm.btExcelClick(Sender: TObject);
var
ExcelApp: Variant;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.WorkBooks.Add;
ExcelApp.WorkSheets[1].Activate;
ExcelApp.Cells[1,5].Value :='sum(A1:A5)';//直接写入公式就可以了sum(A1:A5)
end;