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
end;
end;
end;
ExcelApp.Workbooks.Close(0);
end;