Autor Beitrag
Krefti
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Fr 08.10.10 13:36 
Hallo zusammen,

ist es möglich eine Stringlist direkt nach Excel zu importieren ohne sie vorher abspeichern zu müssen?? Evtl. über die Zwischenablage?? Wenn ja..was muss ich mir da genau anschauen??
Gruß
Krefti
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Fr 08.10.10 14:07 
Hi, hat Delphi7< nicht von Hause aus Word/Excel Komponenten dabei?
So könntest Du die Tabelle, wo es wahrscheinlich hin soll, direkt ansprechen!
Oder schau dir mal diesen link dazu an.
Gruss ALf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Fr 08.10.10 14:08 

_________________
mfg. Joel
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Fr 08.10.10 14:41 
Danke schon mal für eure Antworten,

also wenn ich die SL befüllt habe und dann

ausblenden Delphi-Quelltext
1:
Clipboard.AsText := slWartung.Text;					

mache bekomm ich eine ExceptViolation.

in meiner SL steht mein ganzer schöner Text drin. Woran könnte das liegen??

[Edit]

Hatte vergessen es zu erzeugen;-)
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Fr 08.10.10 14:49 
probier mal clipboard.SetTextBuf(Pchar(sl.text));
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Fr 08.10.10 15:02 
wie gesagt, dass mit dem Text in die Zwischenablage einfügen hat ja inzwischen wunderbar geklappt.

aber das mit dem Excel öffnen und den Inhalt der Zwischenablage einfügen krieg ich irgendwie nicht hin und der oben stehende link hilft mir nicht wirklich weiter.

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
   try
      Excel := GetActiveOleObject('Excel.Application');
    except
      try
       Excel := CreateOleObject('Excel.Application');
       except
         ShowMessage('Microsoft Excel kann nicht starten.');
         exit;
      end;
    end;
   Excel.Visible := true;


wenn ich das so in mein Quellcode reinschreibe bekomm ich eine exception: Vorgang nicht verfügbar. Was heißt das für mich?
hat das möglicherweise etwas mit office 2007 zu tun?
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Fr 08.10.10 15:54 
mh... welchen link meinst Du?
Soll die Excelapp automatisch starten oder manuell durch click auf einem Button oder wie hast Du es eingerichtet?

Gruss ALf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Mo 11.10.10 09:41 
also das befüllen der Stringlist ist eine Suche in einem Filestream wo der String in einer Funktion zusammengebastelt wird und dann in die Stringlist geschrieben wird, anschließend wird in der Prozedur die SL in die Zwischenablage gelegt (funktioniert). Dann soll Excel automatisch starten und die Zwischenablage eingefügt werden. Das mit dem Einfügen in Excel fehlt noch.
Kann mir da noch jemand helfen??

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Clipboard.AsText := slWartung.Text;
  try
      Excel := GetActiveOleObject('Excel.Application');
    except
      try
       Excel := CreateOleObject('Excel.Application');
       except
         ShowMessage('Microsoft Excel kann nicht starten.');
         exit;
      end;
    end;
   Excel.Visible := true;


Danke schon mal
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Mi 13.10.10 15:19 
wollte mal nochmal fragen ob mir evtl. jemand helfen kann??
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 13.10.10 15:54 
Moin!

user profile iconKrefti hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
   try
      Excel := GetActiveOleObject('Excel.Application');
    except
      try
       Excel := CreateOleObject('Excel.Application');
       except
         ShowMessage('Microsoft Excel kann nicht starten.');
         exit;
      end;
    end;
   Excel.Visible := true;
wenn ich das so in mein Quellcode reinschreibe bekomm ich eine exception: Vorgang nicht verfügbar. Was heißt das für mich?
hat das möglicherweise etwas mit office 2007 zu tun?
Probier das mal ausserhalb der IDE zu starten, kommt dann immer noch eine Exception? Ich rate mal: nein. ;) (ggfs. also bei diesem Exception-Typ das Stoppen in der IDE abschalten, dann klappt´s da auch)

Ich verwende ähnlichen Code auch in meinen Projekten, läuft, auch mit O2k7. :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
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 13.10.10 21:49 
Hallo Krefti,

wenn die Fehlermeldung kommt kann man auch einfach Fortsetzen drücken und Excel startet. Wenn Du Deine Stringlist nicht in einem geöffneten Excel-Sheet einfügen willst, sondern immer eine neue Excel-Instanz aufmachen willst reicht es vollkommen wenn Du mit
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
try
    olevEXCEL := CreateOleObject('Excel.Application');
  except
    ShowMessage('Excel konnte nicht gestartet werden !');
    Exit;
  end;
  olevEXCEL.Visible:= TRUE;
eine neue Instanz erstellst. Damit umgehst Du auch Ärger, wenn der Kunde grade die neuste Bilanz offen hat und dann Dein Programm diese mit den Eingaben von Deiner Stringlist kaputt macht.

Bis bald Chemiker
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 14.10.10 08:06 
Ist es eigentlich normal, dass wenn man Excel startet, nichts macht, mein Programm verlassen, dass dann Excel automatisch wieder zugeht??
Sobald ich allerdings eine neue Arbeitsmappe geöffnet habe bleibt es offen.

wie öffne ich über Delphi direkt eine neue Arbeitsmappe??
wie füge ich meinen Inhalt der Zwischenablage automatisch in die Arbeitsmappe ein? Geht das direkt überhaupt?
Danke schon mal.

Gruß
Krefti
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 14.10.10 08:43 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
       FExcel       :=  CreateOleObject('Excel.Application');
       if length(FileName)>0 then FWorkbook:= FExcel.WorkBooks.Open(Filename) else FWorkbook:=FExcel.WorkBooks.Add;
       FActiveSheet:=FExcel.Sheets[1];
FActiveSheet.Paste;
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 14.10.10 09:18 
Vielen Dank für eure hilfe!
Gruß
Krefti
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: Do 14.10.10 20:39 
Hallo Krefti,

ist jetzt vielleicht eine blöde Frage, aber willst Du nur Text nach Excel exportieren? Und warum gehst Du den Umweg über eine Stringlist und schreibst nicht direkt die Daten nach Excel.

Bis bald Chemiker
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 14.10.10 20:53 
@Chemiker

wenn ich große Datenmengen ohne Formatierungen nach Excel schreiben soll z.B. Tabellenexport aus Grids mache ich es auch so ist um Welten schnellen als Zellen zu beschreiben.
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: Do 14.10.10 21:03 
Hallo bummi,

wenn ich große Datenmengen aus einer Datenbank nach Excel übertragen, erstelle ich selber die XLS-Datei, hat denn großen Vorteil das Excel dafür nicht auf den PC vorhanden sein muss.

Bis bald Chemiker