Autor Beitrag
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Fr 02.03.07 16:05 
Hallo.
Vor Kurzem habe ich rausbekommen, wie man im RichEdit Texte verschieden formatieren kann.
Daraufhin habe ich ein Programm geschrieben, mit dem man Text formatieren und als RTF speichern bzw. laden kann.
Es kann alle ASCII Sonderzeichen schreiben. Dann habe ich beim Testen mal eine Excel-Tabelle reinkopiert.
Die Tabellen hat man gesehen. Sie sahen ganz normal aus - eben nach schwarzen Tabellen.
Nun wollte ich mal fragen, ob man das auch von Delphi aus regeln könnte, ohne Excel aufzurufen, in der Entwurfszeit - und wenn ja, wie es geht.
Wäre für eine Antwort sehr dankbar.
____________________
Jakob U.
ssb-blume
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 375
Erhaltene Danke: 7

XP, W7, W8
Deutschland
BeitragVerfasst: Fr 02.03.07 16:25 
Genau darauf suche ich auch noch eine Antwort!

_________________
Brain: an apparatus with which we think we think.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 02.03.07 17:05 
Hallo,

Tabellen im RichEdit anzuzeigen ist nicht so schwierig, eignet sich aber nur zur Anzeige, da kein Zugriff per Code auf die Tabelle bzw. Tabelleninhalte möglich ist.

Interresant ist in diesem Zusammenhang auch Flockes TRtfLabel

Hier mal ein Ansatz mittels Stream:
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:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
var MyMS: TMemoryStream;
    MyRTFList : TStringList;
begin
  MyRTFList := TStringList.Create;
  MyMS := TMemoryStream.Create;
  try
   MyRTFList.Add('{\rtf1'         //Datei-Kopf-Definition
                +'{\fonttbl{'     //Schrift-Tabelle
                +'\f0 Arial;'     //Farbe Nr. 6 aus der Farbtabelle
                +'\f1 Courier;'
                +'\f2 Verdana;'
                +'\f3 Times New Roman;'
                +'}}');           //schließen
   MyRTFList.Add('{\colortbl;'             //Farben-Tabelle (RGB)
                +'\red0\green0\blue0;'       // \cf1 > clBlack
                +'\red255\green0\blue0;'     // \cf2 > clRed
                +'\red0\green128\blue0;'     // \cf3 > clGreen
                +'\red0\green0\blue255;'     // \cf4 > clBlue
                +'\red255\green128\blue0;'   // \cf5 > DE-Orange
                +'\red\green182\blue255;'    // \cf6 > DE-Blau
                +'}');                     //schließen
                //Werte in Twips, Schrifthöhen in 1/2 Punkt
                //1 twip = 1/1440 inch oder 1/20 Punkt.
                //1 Punkt = 20 Twips
                //Round(Tips/1440*PixelsPerInch) = Pixel
   MyRTFList.Add('\sb165'         //Abstand vor(über) dem Text
                +'\sa75'          //Abstand nach(unter)    "
                +'\ri160'         //Einzug rechts (v. Rand)
                +'\f3'            //Schrift Nr. 3 aus der Farbtabelle
                +'\fs18'          //Schriftgröße in 1/2 Punkten > 18/2 = 9 Punkte = 180 Twips
                +'\qr 25.09.2005' // \qr > rechts ausgerichtet
                +'\par');         //Zeilenumbruch
    MyRTFList.Add('\li560'         //Einzug links (v. Rand)
                +'\f0'            //Schrift zurückgesetzt (\f0 Vorgabeschrift)
                +'\fs28\b'        // \b > Fettschrift
                +'\ql'            //links ausgerichtet
                +'\cf6'           //Farbe Nr. 6 aus der Farbtabelle
                +'Eine Tabelle im Standard-RichEdit'
                +'\par');
   MyRTFList.Add('\pard'     //Absatzformatierung zurücksetzen
                +'\plain');  //Zeichenformatierung zurücksetzen
   MyRTFList.Add('\trowd'         //Tabellenabsatz-Definition (in diesem Fall nur eine Zelle)
                +'\trleft160'     //Tabellenabstand zum linken Rand
                +'\trgaph60'      //Abstand zw. linkem Rand und Text in den Zellen
                +'\sb75\sa75'
                +'\cellx8000');   //rechter Rand der Zelle (8000-160 = 7840 Twips Zellenbreite)
   MyRTFList.Add('\fs20\b\intbl'  // \intbl > Textabsatz liegt in Tabellenzelle
                +' Fundamentale Integer-Typen' //Leerzeichen vor dem String !!!
                +'\cell'          //Zellenende
                +'\row');         //Z e i l e n ende
   MyRTFList.Add('\trowd\trleft160\trgaph60\sb75\sa75'
                +'\cellx1000'     //1000-160  =  840 Twips Zellenbreite
                +'\cellx4100'     //4100-1000 = 3100   "         "
                +'\cellx8000');   //8000-4100 = 3900   "         "
   MyRTFList.Add('\fs20\intbl'
                +' Typ\cell'
                +' Wertebereich\cell'
                +' Format\cell\row'
                +'\b0');          //Fettschrift aus
   MyRTFList.Add('\intbl Shortint\cell'
                +'\f1'
                +'\cf2'
                +'         -128'
                +'\cf0'
                +'..127'
                +'\f0\cell'
                +' 8 Bit einschließlich Vorzeichen\cell\row');
                //  es folgen Block-Formatierungen
                //  geöffnete Klammern immer schließen !!!
                //   {\cf2       -32768}     ist identisch mit:
                //    \cf2       -32768\cf0
   MyRTFList.Add('\intbl Smallint\cell\f1{\cf2       -32768}..32767\f0\cell 16 Bit einschließlich Vorzeichen\cell\row');
                //   {\f1{\cf2  -2147483648}..2147483647}       ist identisch mit
                //     \f1\cf2  -2147483648\cf0..2147483647\f0
   MyRTFList.Add('\intbl Longint\cell{\f1{\cf2  -2147483648}..2147483647}\cell 32 Bit einschließlich Vorzeichen\cell\row');
   MyRTFList.Add('\intbl Byte\cell\f1            0..255\f0\cell 8 Bit, besitzt kein Vorzeichen\cell\row');
   MyRTFList.Add('\intbl Word\cell\f1            0..65535\f0\cell 16 Bit, besitzt kein Vorzeichen\cell\row');
   MyRTFList.Add('\pard\fs1\par');
   MyRTFList.Add('\pard\trowd\trleft5450\trgaph60\sb0\sa0\cellx8000');
   MyRTFList.Add('\fs16\cf5\f2\intbl Auszug aus der Delphi 3-Hilfe\cell\row');
                //Text-Ausrichtung nur über Leerzeichen möglich
   MyRTFList.Add('\intbl                                 Lannes\cell\row');
   MyRTFList.Add('');
   MyRTFList.Add('}');
   MyRtfList.SaveToStream(MyMS);
   MyMS.Seek(soFromBeginning,0);
   RichEdit1.PlainText := False;
   RichEdit1.Lines.LoadFromStream(MyMS);
  finally
    MyRTFList.Free;
    MyMS.Free;
  end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Jakob_Ullmann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Sa 03.03.07 12:58 
Nun: Dann haben wir sie ja jetzt!
Dank dir Lannes!
Jakob_Ullmann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Sa 03.03.07 13:01 
Haben wir im Delphi-Forum nicht auch jemanden, der Flocke heißt?
Mir ist's so, als hätte ich das schon mal gehört.
Flocke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54

Win 2000, Win XP, Win 2003, Linux
Delphi 2006 Prof.
BeitragVerfasst: Mo 12.03.07 17:47 
user profile iconJakob_Ullmann hat folgendes geschrieben:
Haben wir im Delphi-Forum nicht auch jemanden, der Flocke heißt?

Ja, haben wir :mrgreen:
Bin aber nicht so oft hier im Forum, da ich im Moment viel zu tun habe...