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 20-05-2003
Avatar de acertij022
acertij022 acertij022 is offline
Miembro
 
Registrado: may 2003
Ubicación: Argentina-Bs. As.
Posts: 233
Poder: 22
acertij022 Va por buen camino
Post duda con excel

mi pregunta es como seria el codigo para saber cuantas lineas del excel tengo utisadas para luego usar esa informacion en un for y recorrer el archivo xls.
el codigo que utlizo para abrir el archivo es el siguiente:

procedure TForm1.Button1Click(Sender: TObject);
var
Excel: _Application;
lcid: integer;
WBk: _Workbook;
WS: _WorkSheet;
Filename: OleVariant;

begin
lcid := LOCALE_USER_DEFAULT;
Excel := CoExcelApplication.Create;
Excel.Visible[lcid] := True;


Filename := 'C:\telbonus\oficinas.xls';
WBk := Excel.Workbooks.Open(Filename, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, LCID);
WS := WBk.Worksheets.Item['Sheet1'] as _Worksheet;
WS.Activate(LCID);


end;
Responder Con Cita
  #2  
Antiguo 21-05-2003
FRANKER FRANKER is offline
Miembro
 
Registrado: may 2003
Ubicación: Elche
Posts: 71
Poder: 22
FRANKER Va por buen camino
Yo lo que hago es localizar la ultima linea de Excel y guardar en una variable el Nº de linea:

Código:
ExcelGoToLastRow(Excel);
MaxRow := ExcelGetRow(Excel);
ExcelGoToTopRow(Excel);
MaxRow es un Integer con la última línea de la hoja de excel. El código de las funciones lo tienes aki :

Código:
procedure TFmImportar.ExcelGoToLastRow(Excel : Variant);
Begin
  Try
    Excel.Selection.End[xlDown].Select;
  Except
  End;
End;

procedure TFmImportar.ExcelGoToTopRow(Excel : Variant);
Begin
  Try
    Excel.Selection.End[xlUp].Select;
  Except
  End;
End;

Function TFmImportar.ExcelGetRow(Excel : Variant): Integer;
Begin
  Result := 1;
  Try
    Result := Excel.ActiveCell.Row;
  Except
    Result := 1;
  End;
End;
Saludos y Suerte!!!
__________________
.:.::FRANKER::.:.
Responder Con Cita
  #3  
Antiguo 21-05-2003
Avatar de acertij022
acertij022 acertij022 is offline
Miembro
 
Registrado: may 2003
Ubicación: Argentina-Bs. As.
Posts: 233
Poder: 22
acertij022 Va por buen camino
Thumbs up

Gracias FRANKER!!!
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 03:38:20.


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