Autor Beitrag
hokowa
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Mi 29.10.08 20:34 
Hallo alle zusammen,

ich möchte in Excel eine bestimmte Zeile löschen.
Dabei gehe ich alle zeilen durch, bei erreichen der besagten Zeile --> Zeile löschen.
Habe einiges probiert, Range, Rows, UsedRange, Item usw.. geht alles nicht.

Bin für jede Hilfe dankbar

Gruß Horst



procedure TMainForm.Loeschen1Click(Sender: TObject);
var
F_name:String;
I, zeile, flcid,l : Integer;
begin
ZipMaster1.FSpecArgs.Clear;
Markierung :=Stringgrid1.Row;

if MessageDlg('Datei ' + StringGrid1.Cells[0, Markierung]+ ' löschen ?', mtinformation, mbYesNo,0) = mrYes then
begin
ZipMaster1.FSpecArgs.Add(StringGrid1.Cells[0, Markierung]);
ZipMaster1.Delete;
F_Name := StringGrid1.Cells[0, Markierung];
ExcelApplication1.Visible[flcid]:=False;
flcid:=GetUserDefaultLCID;
ExcelApplication1.UserControl := True;
ExcelApplication1.DisplayAlerts[flcid] := True;
ExcelApplication1.AskToUpdateLinks[flcid] := False;



f_name:=extractfiledir(Application.ExeName) + '\benutzer.xls';

ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Open(f_name,
emptyParam,
True,
emptyParam,
emptyParam,
emptyParam,
emptyParam,
emptyParam,
emptyParam,
emptyParam,
emptyParam,
// emptyParam,
// emptyParam,
emptyParam,
emptyParam, flcid));
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets.Item[1] as ExcelWorkSheet);
ExcelApplication1.UserControl:=true;


I := 1;
While ExcelWorksheet1.Cells.Item[I, 1].Value = F_Name do
begin
I := I +1;
End;
zeile := I;

ExcelWorksheet1.UsedRange[zeile].Delete; // An der Stelle soll in Excel die Zeile gelöscht werden


ExcelWorksheet1.SaveAs(extractfiledir(Application.ExeName) + '\benutzer.xlsx');
ExcelWorksheet1.Disconnect;
ExcelWorkbook1.Disconnect;
ExcelApplication1.AskToUpdateLinks[flcid] := True;
ExcelWorksheet1.Application.Quit; // Schließt Excel
ExcelWorksheet1.Disconnect;
Excel := 'Unassigned';


end;
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 29.10.08 21:28 

_________________
PROGRAMMER: A device for converting coffee into software.
Chemiker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 194
Erhaltene Danke: 14

XP, Vista 32 Bit, Vista 64 Bit, Win 7 64 Bit
D7, BDS 2006, RAD Studio 2009+C++, Delphi XE2, XE3, VS 2010 Prof.
BeitragVerfasst: Mi 29.10.08 23:15