Board index » delphi » OLE to read from EXCEL into Delphi

OLE to read from EXCEL into Delphi

Hi guys,

 I am having troubles with the following code that reads cells in an Excel
worksheet:
With Windows95 or 98 and excel 97 this code Freezes when it reaches the
863th row (!?)
This problem does not happens when we use windows NT.

Thanks to anyone that could help me .

procedure TForm1.Button1Click(Sender: TObject);
var  Sheet,Book,Excel:Variant;
    curRow,i:integer;
    s,fichier:string;
begin
     if opendialog1.Execute then
     begin
         fichier:=opendialog1.FileName;
         excel:=CreateOLEObject('Excel.Application');
         Book:=Excel.Workbooks.Open(fichier);
         Sheet:=Book.Sheets['PAYROLL'];

         currow:=1;
         repeat

         for I:=1 to 76 do     // my xls file has 76 columns
          begin
            S:=sheet.Cells[CurRow,i];
            memo1.Text:=inttostr(currow) + '   '+inttostr(i) + '   '+s;
            application.ProcessMessages;
          end;
          Inc(CurRow);

          until (s='');

         Book.Close(True);
         Excel.application.quit;

    end;
end;

--
Nicolas Jaumet

 

Re:OLE to read from EXCEL into Delphi


<<Nicolas Jaumet:
With Windows95 or 98 and excel 97 this code Freezes when
it reaches the 863th row (!?)

Quote

Works fine on my Windows 95 OSR2.

I have heard of similar troubles with richedits or memos - I
forget which - with certain hardware installed. Wheel mice,
possibly? Do your problem machines have anything else
in common? Or is there something odd on your 863rd row?
--
Deborah Pate

Other Threads