Ver Mensaje Individual
  #42  
Antiguo 10-01-2012
Avatar de jejo1984
jejo1984 jejo1984 is offline
Miembro
NULL
 
Registrado: jun 2011
Posts: 39
Reputación: 0
jejo1984 Va por buen camino
Claro que si voy a pegar nuevamente el código y de color rojo las líneas donde aparece el error:
Código Delphi [-]
procedure TForm1.BitBtn1Click(Sender: TObject);
const
  xlCellTypeLastCell = $0000000B;
var
 Excel, Sheet,Book: OLEVariant;
 CantRow, CantCol, i, j : Integer;
 RangoMatriz: Variant;
 FileName:String;

begin
  FileName:='C:\SISTEMAPLANILLAS\Libro2.xlsx';
  try
  Excel := CreateOleObject('Excel.Application');
  Excel.Workbooks.Open(FileName);
  ShowMessage(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
      Showmessage(RangoMatriz[i,j]);
      //haces todo lo que necesites hacer
     end;
   end;//for
   finally
   Excel.Quit; //Aquí cerramos la hoja de Excel
   end;
end;

Como comente le agregue StrToInt funca normal pero ya se perdería pues por que ya pasa a integer.
Como podre solucionarlo...
Responder Con Cita