Ver Mensaje Individual
  #8  
Antiguo 09-07-2011
Avatar de newtron
[newtron] newtron is offline
Membrillo Premium
 
Registrado: abr 2007
Ubicación: Motril, Granada
Posts: 4.214
Reputación: 24
newtron Va camino a la fama
No necesitas usar ado para esto, puedes usar el componente ttable e ir añadiendo registros de forma normal.

Código Delphi [-]
procedure TFormImportaExcel.NTButton1Click(Sender: TObject);
var
   appExcel : Variant;
   N, Hoja : SmallInt;
   contenido : String;
   begin
   appExcel := CreateOleObject('Excel.Application');
   appExcel.WorkBooks.Open('C:\ARCHIVO.XLS');
   Hoja:=1;
   N:=0;
   while true do begin
    if Contenido='' then break     Tabla.append;
    Inc(N);     Contenido := appExcel.WorkBooks[1].Worksheets[Hoja].Cells[N,1]; //codigo
    Tabla.FieldByname('CODIGO').AsString:=Contenido;
    Contenido := appExcel.WorkBooks[1].Worksheets[Hoja].Cells[N,2]; //Nombre
    Tabla.FieldByname('NOMBRE').AsString:=Contenido;
    // y así tantos campos como tengas por cada registro 
    Tabla.post;
   end;
   appExcel.Quit;
   appExcel := Unassigned;
 end;
Responder Con Cita