Ich habe mal was zusammengschrieben, da es mich auch interessiert hat wie es funtioniert. Bei mir funktioniert es so wie es soll, falls es das bei dir nicht tut weiß ich nicht genau was du willst

Die Angaben müssen natürlich noch etwas angepasst werden damit sie bei dir passen.
Getestet mit WinVISTA,Office'07,RAD Studio '09
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61:
| unit UStart;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComObj, StdCtrls;
type TForm2 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private procedure DateiÖffnenUndBearbeiten; public end;
var Form2: TForm2; strl:TStringList; Excel:OleVariant;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject); begin Excel:=CreateOleObject('Excel.Application'); strl:=TStringList.Create; try DateiÖffnenUndBearbeiten; finally Excel.Quit; Excel:=Unassigned; strl.Free; end; end;
procedure TForm2.DateiÖffnenUndBearbeiten; VAR row,col:integer; begin excel.WorkBooks.Open(ExtractFilePath(ParamStr(0))+'Test2.xls'); Excel.Sheets[1].Name := 'Name des Sheets'; for col:=1 to 5 do begin strl.Clear; for row :=1 to 8 do begin strl.Add(Excel.Sheets[1].Cells[row,col].Value) end; strl.SaveToFile(ExtractFilePath(ParamStr(0))+Excel.Sheets[1].Cells[1,col].Value+'.txt'); end;
end;
end. |
edit: Delphi Tags hinzugefügt
