Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Auf Excel Tabelle, die auf nem Server liegt zugreifen ? (https://www.delphipraxis.net/15408-auf-excel-tabelle-die-auf-nem-server-liegt-zugreifen.html)

DirkH 28. Jan 2004 11:24


Auf Excel Tabelle, die auf nem Server liegt zugreifen ?
 
Hallo, ich hätte mal eine Frage,

ich würde ganz gerne auf eine Exceltabelle, die auf einem Server im LAN liegt zugreifen.
Wie bekomme ich das hin?
Ein Teil des Programmes sieht momentan so aus:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  WorkBk: _WorkBook; //  WorkBook deklarieren
  WorkSheet: _WorkSheet; //  WorkSheet deklarieren
  XLApp: TExcelApplication;
  _lcid: LCID;
begin
  _lcid := GetUserDefaultLCID;
  XLApp := TExcelApplication.Create(Self);
  try
    XLApp.Connect;
    try
      // WorkBooks zur ExcelApplication hinzufügen
      XLApp.Workbooks.Open('\\170.136.77.35\test\test.xls', emptyParam, emptyParam,
        emptyParam, emptyParam, emptyParam, emptyParam, emptyParam,
        emptyParam, emptyParam, emptyParam, emptyParam, EmptyParam,
        _lcid); // WorkBooks zur ExcelApplication hinzufügen
      WorkBk := XLApp.WorkBooks.Item[1]; // erstes WorkBook auswählen
      WorkSheet := WorkBk.WorkSheets.Get_Item(strtoint(Edit1.text)) as _WorkSheet;
      ShowMessage(Worksheet.Cells.Item[(strtoint(Edit2.Text)), (strtoint(Edit3.Text))].Value);
    finally
      XLApp.Disconnect;
    end;
  finally
    XLApp.Quit;
  end;
end;

Nun weiss ich nicht, wie ich die Verbindung zu dem Server hinbekommen kann ;(
Es geht ja nun mehr oder weniger nur um:
Delphi-Quellcode:
XLApp.Workbooks.Open('\\170.136.77.35\test\test.xls', .... );
wenn ich die Tabelle lokal, also
Delphi-Quellcode:
XLApp.Workbooks.Open('c:\test\test.xls', .... );
anspreche, klappt das alles.
Nun weiss ich wie gesagt nicht, wie ich die auf dem Server ansprechen soll/kann. Welche Komponenten ich dafür brauche, usw...

Ich hoffe es kann mir hier jemand helfen.

Ach ja, ich nutze Delphi7 Enterprise und Office 2000

Danke schon mal im Vorraus, DirkH

jority 28. Jan 2004 11:40

Re: Auf Excel Tabelle, die auf nem Server liegt zugreifen ?
 
hi,
also ich hab es mal so probiert.

Delphi-Quellcode:
var excel:variant;
begin
   excel:= CreateOLEObject('Excel.Application');
   excel.visible:=true;
   excel.workbooks.add;
   Excel.Workbooks.Open('\\192.168.2.151\edv\Tüv-Termin.xls', emptyParam, emptyParam); // WorkBooks zur ExcelApplication hinzufügen
end;
bei mir funzt es so.
gruß Jority

DirkH 28. Jan 2004 12:41

Re: Auf Excel Tabelle, die auf nem Server liegt zugreifen ?
 
Danke für die sehr schnelle Hilfe.

Ich weiss nicht, was ich sagen soll. :oops:
Bei mir funktioniert es nun auch auf einmal :oops:

Hab 2 mal neu gestartet und das Programm läuft nun.

Ich denke das war mein eigener dummer fehler. Der Server lässt sich wohl nur äusserst Case Sensitive ansprechen ;( Hab das total verpeilt.

Delphi-Quellcode:
'\\170.136.77.35\test\test.xls'
ging nicht

Delphi-Quellcode:
'\\170.136.77.35\Test\test.xls'
klappt. Also T statt t

Sorry für die Zeit, die ich dir damit geklaut habe ;) und danke nochmal,


Greetz DirkH


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:43 Uhr.

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