Autor Beitrag
Gandalf
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Di 19.08.03 13:56 
Ich habe eine SQL Tabelle exportiert und sie hat die folgende Form:

ausblenden volle Höhe Quelltext
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:
DROP TABLE IF EXISTS bb2_privatemessage;

CREATE TABLE mr1_privatemessage (

  privatemessageid int(11) unsigned NOT NULL auto_increment, 

  folderid int(11) unsigned NOT NULL DEFAULT '0', 

  senderid int(11) unsigned NOT NULL DEFAULT '0', 

  recipientid int(11) unsigned NOT NULL DEFAULT '0', 

  subject varchar(250) NOT NULL, 

  message text NOT NULL, 

  sendtime int(11) unsigned NOT NULL DEFAULT '0', 

  allowsmilies tinyint(1) NOT NULL DEFAULT '1', 

  allowhtml tinyint(1) NOT NULL DEFAULT '0', 

  allowbbcode tinyint(1) NOT NULL DEFAULT '1', 

  allowimages tinyint(1) NOT NULL DEFAULT '1', 

  showsignature tinyint(1) NOT NULL DEFAULT '0', 

  iconid int(11) unsigned NOT NULL DEFAULT '0', 

  view int(11) unsigned NOT NULL DEFAULT '0', 

  reply tinyint(1) NOT NULL DEFAULT '0', 

  forward tinyint(1) NOT NULL DEFAULT '0', 

  deletepm tinyint(1) NOT NULL DEFAULT '0', 

  tracking tinyint(1) NOT NULL DEFAULT '0', 

  PRIMARY KEY (privatemessageid), 

  KEY folderid (folderid), 

  KEY iconid (iconid), 

  KEY senderid (senderid, deletepm), 

  KEY recipientid (recipientid, deletepm)

);
INSERT INTO mr1_privatemessage VALUES


Danach folgen die Werte
ausblenden Quelltext
1:
(1,0,1,12,'Betreff','Inhalt bla bla',1043271992,1,0,1,1,1,0,1,0,0,2,0)					
, die jeweils von den nächsten Inhalten durch Kommas getrennt sind.

Ich möchte eine Programm schreiben, dass die Werte in Klammern zerpflückt und in Tabellen, die man mit Excel öffnen kann, einfügt.

Ich weiß leider nicht, man auf die Zeichen eines Memo bzw. RichText Feldes zugreifen kann. Erfahrung habe ich bisher nur mit der Textbearbeitung von normalen Strings aus Editfeldern.

Kann mir jemand Ratschläge geben und evtl einen kleinen Teil vortexten?

Die Suchenfunktion habe ich 30mins benutzt, war aber am Ende erfolglos.

danke, Gandalf
BeniSchindler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 82

Win 2k / suse9.1
D7 Prof / Kylix 3
BeitragVerfasst: Mi 20.08.03 10:38 
So wie du das beschrieben hast, gehört das eigentlich in die Sparte für Dateizugriffe. :wink:

Also wenn du über die SQL-Datei gehen willst/musst, so würde ich sie mir einfach in eine StringList laden. Ich hab gerade eh nix vor für die nächsten 10 min. also schauen wir doch mal wie ich das machen würde. ... mmh... also nach dem folgendem Code dürftest du mit deinen "String"-Bearbeitungskentnissen weiter kommen.


ausblenden volle Höhe Delphi-Quelltext
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:
procedure SQLfileToTablefile(ASQLFilePath : String; ATableFilePath: string)
var
  SL : TStringList;      // a Stringlist to store the content of the SQLFile
  NewFile : TStringList; // a Stringlist were i create the new File.
  TempString : string;   // a string were i temporarily save the actual file line
  Index : integer;       // index to go through the SL
begin
  //create a StringList
  SL := TStringList.create;
  with SL do try
    //load the Strings from the file into the StringList
    LoadFromFile(ASQLFilepath);
    //now we could work with the Strings and insert them into the new File
    NewFile := TStringList.create;
    With NewFile do try
      //Go through all lines of the SQLFile.
      for index := 0 to high(SL) do begin
        //Get the actual line
        TempString := SL.Strings[index];

        // edit the TempString
        TempString := copy(TempString,1,5) // or what ever...
        // i would call a new function in witch i edit the line.
        // like: TempString := GetTAbleFileLine(TempString {string were i extract the tablefile line from});

        //add the newLine to the NewFile-Stringlist
        Add(TempString);
      end;
      //Save new File
      SaveToFile(ATableFilePath);
    Finally
      Free; //free NewFile
    End;
  finally
    Free; //free SL
  end;
end.


Achja und bei Excel&co solltest du ein File erstellen mit ',' oder Tab (''+chr(9)+'') Trennung

mfg |{arr' AcaRn

_________________
Result := 42; Application.ProcessMessages;