Ver Mensaje Individual
  #3  
Antiguo 07-07-2010
Avatar de Caro
*Caro* Caro is offline
Moderadora
 
Registrado: jul 2004
Ubicación: Cochabamba, Bolivia
Posts: 2.544
Reputación: 22
Caro Va por buen camino
Hola TecnoBestia, ademas de hacerlo con Ado como te dijo Neftali, también puedes hacerlo de esta forma:

Código Delphi [-]
const
  xlCellTypeLastCell = $0000000B;
var
 Excel, Sheet: OLEVariant;
 CantRow, CantCol, i, j : Integer;
 RangoMatriz: Variant;
begin
  FileName := 'C:\Archivo.xls';
  Excel := CreateOleObject('Excel.Application');
  Excel.Workbooks.Open(FileName);
 
  Sheet := Excel.Workbooks[ExtractFileName(FileName)].WorkSheets[1];
  Sheet.Activate;
  Sheet.Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Activate;
 
  CantRow := Excel.ActiveCell.Row;
  CantCol := Excel.ActiveCell.Column;
 
  RangoMatriz := Excel.Range['A1', Excel.Cells.Item[CantRow,CantCol]].Value;
 
  StringGrid1.ColCount := CantCol+1;
  StringGrid1.RowCount := CantRow+1; 

  for i:=1 to CantRow do
   begin
    for j:=1 to CantCol do
      StringGrid1.Cells[j,i] := RangoMatriz[i,j]; 
   end;

Saluditos
__________________
Disfruten cada minuto de su vida a lado de sus seres queridos como si fuese el ultimo, uno nunca sabe lo que puede pasar.
Responder Con Cita