stu76
Messages postés
186
Date d'inscription
samedi 5 mars 2005
Statut
Membre
Dernière intervention
17 février 2008
1
20 nov. 2005 à 10:58
Voici un exemple de source d'exportation de données vers excel, c'est un source que j'avais trouver dans un book et que j'avais modifier pour l'adapter à mon application qui est également en paradox.
Ce source n'est peut-être pas parfait mais toujours est-il qu'il répondait à ma demande de l'époque. Voilà si ca peut aider temps mieux. Sinon si tu cherche une commande encore plus précise ou plus spécifique dit moi quoi et je cherche dans mais autre source si je trouve quelque chose qui se rapproche plus à tes attentes.
Code :
procedure TForm1.Exporter1Click(Sender: TObject);
var
XLApp : Variant;
NbLigne : Integer;
begin
if MessageDlg('CONFIRMEZ EXPORTATION DE VOTRE FICHIER VERS EXCEL ?', mtConfirmation, [mbOK, mbCancel], 0) = mrOk then
begin
try
XLApp := CreateOleObject('Excel.Application');
except
ShowMessage('Démarrage de Microsoft Excel impossible');
Exit;
end;
XLApp.Visible := True;
XLApp.Workbooks.Add;
XLApp.Cells[1,1].Value := 'NOM';
XLApp.Cells[1,2].Value := 'PRENOM';
XLApp.Cells[1,3].Value := 'ADRESSE PERSO';
XLApp.Cells[1,4].Value := 'ADRESSE PROF';
XLApp.Cells[1,5].Value := 'CODE';
XLApp.Cells[1,6].Value := 'VILLE';
XLApp.Cells[1,7].Value := 'TELEPHONE';
XLApp.Cells[1,8].Value := 'FAX';
XLApp.Cells[1,9].Value := 'GSM';
XLApp.Cells[1,10].Value := 'CIVILITE';
XLApp.Cells[1,11].Value := 'EMAIL';
XLApp.Cells[1,12].Value := 'CELIBATAIRE';
XLApp.Cells[1,13].Value := 'PROFESSION';
NbLigne :=2;
with Table1 do
begin
first;
while not(Eof) do
begin
XLApp.Cells[NbLigne,1].Value := FieldByName('NOM').AsString;
XLApp.Cells[NbLigne,2].Value := FieldByName('PRENOM').AsString;
XLApp.Cells[NbLigne,3].Value := FieldByName('ADRESSE PERSO').AsString;
XLApp.Cells[NbLigne,4].Value := FieldByName('ADRESSE PROF').AsString;
XLApp.Cells[NbLigne,5].Value := FieldByName('CODEPOSTAL').AsString;
XLApp.Cells[NbLigne,6].Value := FieldByName('VILLE').AsString;
XLApp.Cells[NbLigne,7].Value := FieldByName('TELEPHONE').AsString;
XLApp.Cells[NbLigne,8].Value := FieldByName('FAX').AsString;
XLApp.Cells[NbLigne,9].Value := FieldByName('GSM').AsString;
XLApp.Cells[NbLigne,10].Value := FieldByName('CIVILITE').AsString;
XLApp.Cells[NbLigne,11].Value := FieldByName('EMAIL').AsString;
XLApp.Cells[NbLigne,12].Value := FieldByName('CELIBATAIRE').AsBoolean;
XLApp.Cells[NbLigne,13].Value := TClient.FieldByName('NOM_PROFESSION').AsString;
inc(NbLigne);
Next;
end;
end;
end;
end;
end;
@+
Stu76