Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Erzeugte Exceldatei speichern (https://www.delphipraxis.net/43771-erzeugte-exceldatei-speichern.html)

tylix 8. Apr 2005 13:41


Erzeugte Exceldatei speichern
 
Hallo,

ich erzeuge hiermit eine Exceldatei, dies funktioniert aber auch,
jedoch möchte ich diese erzeugte Datei automatisch speichern.

Ich finde leider nicht die richtige Lösung such schon seit ca. 1 Std. find´s aber nicht.

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  excel: TExcelApplication;
  SaveChanges: OleVariant;
  wb: _WorkBook;

  ws: _WorkSheet;

  a,zl,i, lcid: Integer;
  ze,sp:integer;
  z, y,x: string ;


begin
    lcid := GetUserDefaultLCID;
    excel := TExcelApplication.Create(self);
    excel.Connect;
    WB := Excel.Workbooks.Add(EmptyParam, LCID);;
    excel.Visible[lcid] := True;
    excel.Cells.Item[1, 1].Value := 'Ident';
    Excel.Cells.Item[1, 1].Interior.Color := clGreen;
    excel.Cells.Item[1, 2].Value := 'PR_ANREDE';
    Excel.Cells.Item[1, 2].Interior.Color := clGreen;
    excel.Cells.Item[1, 3].Value := 'PR_NAMEGES';
    Excel.Cells.Item[1, 3].Interior.Color := clGreen;
    excel.Cells.Item[1, 4].Value := 'PR_CO';
    Excel.Cells.Item[1, 4].Interior.Color := clGreen;
    excel.Cells.Item[1, 5].Value := 'Strasse';
    Excel.Cells.Item[1, 5].Interior.Color := clGreen;
    excel.Cells.Item[1, 6].Value := 'PLZ';
    Excel.Cells.Item[1, 6].Interior.Color := clGreen;
    excel.Cells.Item[1, 7].Value := 'ORT';
    Excel.Cells.Item[1, 7].Interior.Color := clGreen;
    excel.Cells.Item[1, 8].Value := 'Briefanr';
    Excel.Cells.Item[1, 8].Interior.Color := clGreen;
    excel.Cells.Item[1, 9].Value := 'Brief';
    Excel.Cells.Item[1, 9].Interior.Color := clGreen;

end;
Wäre super wenn ihr mir dabei helfen könntet.

Danke euch.

Vjay 8. Apr 2005 14:29

Re: Erzeugte Exceldatei speichern
 
Delphi-Quellcode:
WB.Save(...);

tylix 8. Apr 2005 14:33

Re: Erzeugte Exceldatei speichern
 
hi,

ds habe ich schon probiert, nur sagt er mir dann missing .....,

möchte es z.b. unter c:\tylix.xls speichern

Boombuler 11. Apr 2005 12:57

Re: Erzeugte Exceldatei speichern
 
Delphi-Quellcode:
Excel.ActiveWorkbook.SaveAs(Dateiname);
Greetz
Boombuler

Tonic1024 11. Apr 2005 13:22

Re: Erzeugte Exceldatei speichern
 
Ich könnte noch folgendes anbieten:

Delphi-Quellcode:
  // Beenden und speichern
  [WorkBook].Close(true, Excelfile, EmptyParam, _lcid);
 
  // Beenden ohne speichern
  [WorkBook].Close(false);
Der erste Wert (Bool) steht dafür ob gesaved werden soll oder nicht.
Der Zweite ist dann der Dateiname mit Pfad. Fällt weg wenn nicht gespeichert werden soll.

Ganz nützlich wenn man die Instanz eh schließen will...

MfG

Tonic


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:47 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz