Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 05-07-2013
steelha steelha is offline
Miembro
 
Registrado: mar 2012
Posts: 158
Poder: 13
steelha Va por buen camino
Eliminar Fila en Hoja de Excel

Buenas, he tratado de buscar como eliminar una fila de un archivo en excel desde delphi, y he tratado varios métodos sin ningún resultado acá dejo parte del código para que sea verificado a ver que le hace falta. Aaah Al final de eliminar las filas me interesa guardar el archivo con los cambios.

Código Delphi [-]
procedure TfrmGenerarTxt.Button1Click(Sender: TObject);
Var
  i     : Integer;
  j     : Integer;
  si    : String;
  h     : integer;
  ultfil: Integer;
  excel : OleVariant;
  Book  : OleVariant;
  hoja  : _Worksheet;
begin
  with UArchivoExcel do
  begin
    InitialDir := GetCurrentDir;
    Options := [ofFileMustExist];
    Filter  := 'Excel 97-2003|*.xls|Excel 2007-2010|*.xlss';
    FilterIndex := 1;

    if Execute then
      lstArchivo.Lines.Text := FileName
    else
      ShowMessage('Selección de Archivo Cancelada por el usuario');
  end;

  try
    ExcelApp.Workbooks.Open(Trim(lstArchivo.Lines.Text), EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 
                            EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0);
    hoja := ExcelApp.Worksheets.Item[1] as _WorkSheet;
    ExcelApp.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
    ultfil := ExcelApp.ActiveCell.Row;
    ShowMessage(IntToStr(ultfil));

  finally
    ShowMessage(IntToStr(ultfil));
    for i:=1 to ultfil do
    begin
      hoja.Cells.Range['A'+IntToStr(i),'A'+IntToStr(i)].Activate;
      If not VarIsNumeric(LeftStr(ExcelApp.Range['A'+IntToStr(i),'A'+IntToStr(i)].Value,1)) then
      begin
//        hoja.Cells.Range['A'+IntToStr(i),'A'+IntToStr(i)].Row.Delete;
      end;
    end;
  end;
  ExcelApp.Workbooks.Close(0);
end;

Última edición por Casimiro Notevi fecha: 05-07-2013 a las 21:33:19.
Responder Con Cita
 



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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Eliminar fila de un StringGrid santiago14 Varios 6 28-06-2014 18:04:02
Eliminar la ultima hoja de un excel Veelicus Varios 0 19-07-2011 15:22:13
Agregar datos en una hoja de excel donde la fila inicial puede variar JoAnCa Servers 9 22-08-2008 15:07:42
eliminar fila de un dbgrid Choclito Varios 1 31-03-2007 17:50:44
Eliminar espacio en blanco al final de la hoja judit25 Impresión 3 14-08-2006 17:55:14


La franja horaria es GMT +2. Ahora son las 14:38:13.


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