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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| procedure StringGrid_Excel(StringGrid1, StringGrid2 : TJvStringGrid);
var
// Pour Excel
vMSExcel : variant; // Ouverture
vXLWorkbook, vXLWorkbooks : variant; // Classeur
aFeuille : AnsiString; // nom de la Feuille
vWorksheet : variant; // Feuille
// Pour le programme
i: Integer;
x,y: Integer;
t: Integer;
StringGridJv : TjvStringGrid;
LigneDepart: integer;
Begin
// On test si excel est présent
if ApplicationInstalled('Excel.Application',HKEY_CLASSES_ROOT) then
Begin
// Fenêtre d'attente avant affichage du résultat
Fattente := TFattente.Create(Application);
Try
Fattente.Show;
FAttente.JvXPProgressBar1.Position := 2;
FAttente.Label1.Caption := 'Initialisation...';
Application.ProcessMessages;
// Ouverture Excel
vMSExcel := CreateOleObject('Excel.Application');
vMSExcel.Visible := False;
FAttente.JvXPProgressBar1.Position := FAttente.JvXPProgressBar1.Position + 3;
FAttente.Label1.Caption := 'Ouverture de la liaison avec Excel...';
Application.ProcessMessages;
// Création d'un nouveau classeur
vXLWorkbooks := vMSExcel.Workbooks;
vXLWorkbook := vXLWorkbooks.Add;
FAttente.JvXPProgressBar1.Position := FAttente.JvXPProgressBar1.Position + 2;
FAttente.Label1.Caption := 'Création du classeur...';
Application.ProcessMessages;
// On travail sur la 1ère feuille de calcul de ce classeur
aFeuille := 'Feuil1';
vWorksheet := vXLWorkbook.WorkSheets[aFeuille];
FAttente.JvXPProgressBar1.Position := FAttente.JvXPProgressBar1.Position + 3;
FAttente.Label1.Caption := 'Création des ''Feuil''...';
Application.ProcessMessages;
For t := 1 to 2 do
Begin
// La je fais le boulot // |