Hello Julian,
I have a problem with wprichtext1. I have just a table in my WpRichText and I would like to save it and to reload it. I created a short example here.
When I load the file RTF, the file is displayed but the table does no longer exist.
In the following example, before saving, anything is ok.
After reloading, the table name is not displayed and rowCount is 0.
But when I display in notepad the rtf file, all of the informations are here !!!
Code
var
Form1: TForm1;
table : TParagraph;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var cell, row : TParagraph;
rowstyle : TWPTableRowStyle;
i : integer ;
begin
WPRichText1.EditOptions := [wpNoEditOutsideTable];
WPRichText1.WPToolBar := WpToolBar1 ;
WPRichText1.ActiveText := WPRichText1.BodyText;
WPRichText1.ActiveText.Clear(true);
table := WPRichText1.ActiveText.CreateTable(nil);
table.ASet(WPAT_BorderFlags, WPBRD_DRAW_All4);
table.Name := 'tab_unique' ;
for i := 1 to 3 do
begin
rowstyle := table.CreateRow(nil, true);
cell := rowstyle.InputCell;
cell.Name := chr(64+i) ;
cell.ClearCharAttr(true);
cell.ADel(WPAT_BorderFlags) ;
cell.ASet(WPAT_BorderFlags, WPBRD_DRAW_Bottom );
cell.ASetFontName('Arial');
cell.ASet(WPAT_CharFontSize, 9*100);
cell.ASetColor(WPAT_CharColor, clBlack);
cell.ASetCharStyle(true,1);
cell.ClearCharAttr(true);
cell.SetText(chr(64+i));
row := table.EndRow(rowstyle);
end ;
WPRichText1.EditOptions := [wpNoEditOutsideTable];
WPRichText1.Refresh;
showmessage(inttostr(table.RowCount)) ;
wprichtext1.SaveToFile( 'fic1.rtf',false,'' ) ;
table.Name := 'empty' ;
while Table.Rows[0] <> nil do
table.Rows[0].DeleteParagraph;
wprichtext1.LoadFromFile( 'fic1.rtf' , true , '' ) ;
WPRichText1.ReformatAll(false,false);
showmessage(table.name) ;
showmessage(inttostr(table.RowCount)) ;
end;
Alles anzeigen
Any help is welcome.
Bye