1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| MonClasseur := ExcelApplication1.Workbooks.Add(xlWBATWorksheet,0);
ExcelApplication1.SheetsInNewWorkbook[0]:=8;
MonClasseur:=ExcelApplication1.Workbooks.Add(EmptyParam,0);
Monclasseur.Sheets.Add(EmptyParam,EmptyParam,1,xlWBATWorksheet,0);
MaFeuille:=MonClasseur.Worksheets[1] as _worksheet;
MaFeuille:=MonClasseur.Worksheets['feuil1'] as _worksheet;
Query_Sit_Agt.sql.Clear;
Query_Sit_Agt.sql.Add('Select agent.a_nom as nom, agent.a_prenom as prenom , agent.a_matricule as matricule, agent.a_charge as charge, agent.a_dotation_med as dotation');
Query_Sit_Agt.sql.Add(', sum(f_charge_sonabel) as f_conso, a_dotation_med - sum(f_charge_sonabel) as f_solde from agent, fiche');
Query_Sit_Agt.sql.Add('Where fiche.f_Annee = ' + QuotedStr(Edit1.text));
Query_Sit_Agt.sql.Add('And agent.centre = 362');
Query_Sit_Agt.sql.Add('And agent.a_matricule = Fiche.a_matricule');
Query_Sit_Agt.sql.Add('Group by agent.a_nom, agent.a_prenom, agent.a_matricule, a_charge, a_dotation_med') ;
Query_Sit_Agt.sql.Add('Order by agent.a_matricule');
Query_Sit_Agt.Open;
MaFeuille.Cells.Item[1,1].Value:='NOM';
MaFeuille.Cells.Item[1,2].Value:='PRENOM';
MaFeuille.Cells.Item[1,3].Value:='DOTATION';
MaFeuille.Cells.Item[1,3].Value:='CHARGE';
MaFeuille.Cells.Item[1,4].Value:='CONSO';
MaFeuille.Cells.Item[1,5].Value:='SOLDE';
MaFeuille.Range['A2', 'A200'].Value:= Query_Sit_Agt.fieldbyname('nom').AsString;
MonClasseur.Save(0);
MonClasseur.SaveAs('c:\tuto\excel.xls',
EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,
xlNoChange,EmptyParam,EmptyParam,EmptyParam,EmptyParam,0); |
Partager