var
aExcel, aSheet, aQueryTable: Variant;
sQueryText, sFileName: String;
aExcel := CreateOleObject('Excel.Application');
aExcel.WorkBooks.Add(-4167);
aSheet := aExcel.ActiveWorkbook.WorkSheets[1];
sQueryText := 'select * from Table1';
aQueryTable := aSheet.QueryTables.Add(Format('OLEDB;%s;', [ADOConnection.ConnectionString]), aSheet.Range['A1', 'A1'], sQueryText);
aQueryTable.RefreshStyle := 2;
aQueryTable.Refresh(False);
aSheet := aExcel.ActiveWorkbook.WorkSheets[2];
sQueryText := 'select * from Table2';
aQueryTable := aSheet.QueryTables.Add(Format('OLEDB;%s;', [ADOConnection.ConnectionString]), aSheet.Range['A1', 'A1'], sQueryText);
aQueryTable.RefreshStyle := 2;
aQueryTable.Refresh(False);
aSheet := aExcel.ActiveWorkbook.WorkSheets[3];
sQueryText := 'select * from Table3';
aQueryTable := aSheet.QueryTables.Add(Format('OLEDB;%s;', [ADOConnection.ConnectionString]), aSheet.Range['A1', 'A1'], sQueryText);
aQueryTable.RefreshStyle := 2;
aQueryTable.Refresh(False);
……
aExcel.ActiveWorkbook.SaveAs(sFileName);