steelha,
Cita:
Empezado por steelha
..he tratado de buscar como eliminar una fila de un archivo en excel desde Delphi...sin ningún resultado...
|
Revisa este código:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComObj;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
xlOpenXMLWorkbook = 51;
var
Excel, WrkS : Variant;
FileExcel : String;
i : Integer;
begin
FileExcel := ExtractFilePath(Application.ExeName) + 'TestExcel.xlsx';
try
Excel := CreateOleObject('Excel.Application');
Excel.DisplayAlerts := False;
Excel.Visible := False;
Excel.Workbooks.Open(FileExcel);
WrkS := Excel.Worksheets[1];
WrkS.Cells.ClearContents;
for i := 1 to 25 do
begin
WrkS.Cells[i, 1].Value := i;
WrkS.Cells[i, 2].Value := 'Item-'+IntToStr(i);
WrkS.Cells[i, 3].Value := 'Description-'+IntToStr(i);
end;
for i := 25 downto 21 do
WrkS.Rows[i].Delete;
WrkS.Range['A1:C6'].EntireRow.Delete(EmptyParam);
WrkS.Range['A2:C2'].Value := 777;
WrkS.SaveAs(FileExcel,xlOpenXMLWorkbook);
finally
Excel.Quit;
Excel := Unassigned;
WrkS := Unassigned;
end;
end;
end.
El código anterior es
un ejemplo de manipulación de datos por medio de Automatización en Excel con Delphi 7 y Excel 2010.
Te sugiero consultar esta información:
Espero sea útil
Nelson.