var
appexcel,excelworks:OleVariant;i,j:integer;
begin
appExcel:=CreateOleObject('Excel.Application');
appExcel.visible:=true;
appExcel.Workbooks.add;
ExcelWorks:=appExcel.Sheets.item(1);
i:=0;
while not mquery.eof do begin
for j:=0 to mquery.fieldcount-1 do begin
case j of
0:excelworks.range('A'+inttostr(i)).formula:=mquery.fields(0).value;
1: excelworks.range('B'+inttostr(i)).formula:=mquery.fields(1).asstring;
2: excelworks.range('C'+inttostr(i)).formula:=mquery.fields(2).asstring;
3: excelworks.range('D'+inttostr(i)).formula:=mquery.fields(3).asstring;
4: excelworks.range('E'+inttostr(i)).formula:=mquery.fields(4).asstring;
end;
end;
i:=i+1;
mquery.next;
end;
end;