![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
#1
|
||||
|
||||
|
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; |
|
#2
|
|||
|
|||
|
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); 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;
__________________
.:.::FRANKER::.:. |
|
#3
|
||||
|
||||
Gracias FRANKER!!! |
![]() |
|
|
|