Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Servers
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 03-09-2011
LuisAlf:: LuisAlf:: is offline
Miembro
 
Registrado: nov 2009
Posts: 60
Poder: 15
LuisAlf:: Va por buen camino
Pudiste solucionar este problema de alguna forma?
Responder Con Cita
  #2  
Antiguo 08-09-2011
Avatar de juanlaplata
juanlaplata juanlaplata is offline
Miembro
 
Registrado: ene 2007
Ubicación: La Plata, Bs. As. (Argentina)
Posts: 212
Poder: 18
juanlaplata Va por buen camino
Importar Excel:
Código Delphi [-]
procedure TForm80.ExcelClick(Sender: TObject);
var
 Excel, Sheet: OLEVariant;
 CantRow, CantCol, i, j : Integer;
 RangoMatriz: Variant;
 FileName :string ;
begin

      OpenDialog.Title := 'Excel a Importar ...';
      OpenDialog.DefaultExt := 'xls';
      OpenDialog.InitialDir := ExtractFilePath(Application.ExeName);
      OpenDialog.FileName := '';
      OpenDialog.Filter:='Archivos Excel (*.xls)|*.xls';
      OpenDialog.FilterIndex:=1;
      if(OpenDialog.Execute)then
           begin
           if(OpenDialog.FileName <> '')then
              begin  

              FileName := OpenDialog.FileName;
              Excel := CreateOleObject('Excel.Application');
              Excel.Workbooks.Open(FileName);

              Sheet := Excel.Workbooks[ExtractFileName(FileName)].WorkSheets[1];
              Sheet.Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Activate;

              CantRow := Excel.ActiveCell.Row;
              CantCol := Excel.ActiveCell.Column;

              RangoMatriz := Excel.Range['A1', Excel.Cells.Item[CantRow,CantCol]].Value;

              for i:=1 to CantRow do
                 begin
                      for j:=1 to CantCol do
                       begin

                            Table1.Append;
                            Table1Campo.AsString := trim(RangoMatriz[i,j]);
                            Table1.Post;

                       end; // for j
                 end;//for i
              Excel.quit;
              end;
           end;
end;

Este Codigo, no es de mi autoria, deberia colocar la fuente, que la verdad, no la tengo en este momento.
Lo que hace es recorrer todas las celdas del Excel y cargar en una tabla.
La idea es ver como se hace y q cada uno lo reprograme a gusto y necesidad.
Saludos.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 11:44:48.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi