Bonjour

J'ai ce code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
procedure TForm1.Button5Click(Sender: TObject);
var
 xlapp,shet : OleVariant;
 i,i1,j : integer;
 s: string;
begin
//------------------------------------------------------------------------------
xlapp := createOleObject ('Excel.Application');
shet := createOleObject('Excel.sheet');
shet := xlapp.workbooks.add;
i1 := 0;
for i := 0 to dbgrid1.Columns.Count-1 do
  begin
    if dbgrid1.Columns[i].Visible = true then
    begin
      xlapp.cells(1,i1+1):=dbgrid1.Columns[i].Title.Caption;
      inc(i1);
    end;
    dbgrid1.DataSource.DataSet.First;
    j:=2;
    while not dbgrid1.DataSource.DataSet.Eof do
    begin
      i1 := 0;
      for i := 0 to dbgrid1.Columns.Count-1 do --------------------------> Affectation à la variable de boucle FOR 'i' error
 
      begin
        if dbgrid1.Columns[i].Visible = true then
        begin
          if dbgrid1.Columns[i].FieldName = 'NumCert' then
          begin
            xlapp.cells(j,i1+1):=j-1;
          end
          else
          begin
            xlapp.cells(j,i1+1):=dbgrid1.Fields[i].AsString;
          end;
          inc(i1);
        end;
      end;
 
      inc(j);
      dbgrid1.DataSource.DataSet.Next;
 
    end;
    s:= extractfilepath(application.ExeName)+'1.xlsx';
    shet.saveas( s);
    shet.close;
  end;
end;
lorsque je le compile, j'obtiens ce message d'erreur:
Affectation à la variable de boucle FOR 'i'