Text with ansi code in table cells

General TRichView support forum. Please post your questions here
Post Reply
G van Bragt
Posts: 1
Joined: Sun Sep 04, 2005 11:49 am

Text with ansi code in table cells

Post by G van Bragt »

Can someone help me please.

I have 2 questions:
1) why cant i load an rtf file made by MS Word
2) i made a procedure wich searches a table for some words and when a specific word is found the text has to be replaced

I made the following procedure:

procedure TForm1.SearchDocument;
var item: TCustomRVItemInfo;
table: TRVTableItemInfo;
Data: Integer;
r,c,cs,rs,i: Integer;

rv: TCustomRichViewEdit;
ItemNo: Integer;
s,s1,s2,s3:string;
p:tstringlist;
begin

if not rve.GetCurrentItemEx(TRVTableItemInfo, rv, item) then
exit;
table := TRVTableItemInfo(item);
ItemNo := rve.GetItemNo(table);

for r:= 0 to table.Rows.Count -1 do
for c:= 0 to table.Rows[r].Count -1 do
begin
for i:= 0 to table.Cells[r,c].ItemCount -1 do
begin

s := Replace(table.Cells[r,c].GetItemText(i),rve,i);

s1:= Replace(s,rve,i);
s2:= Replace(s1,rve,i);
s3:= Replace(s2,rve,i);



// showmESSAGE('S '+S);
// showmESSAGE('S1 '+S1);
// showmESSAGE('S2 '+S2);
// showmESSAGE('S3 '+S3);

table.Cells[r,c].SetItemTextA(i,s3); // gives s3 as a long
string and
// ansi code #13#10 or #9 does not work
table.Cells[r,c].AddTextNLA(s3,0,-1,0); // goes wel with ANSI code
end;
rve.format;
end;
uReportShared.formatTable(9,table);

end;

However i need the procedure wich doesnt work:
table.Cells[r,c].SetItemTextA(i,s3); so the text is replaced

Please can someone help me[/b]
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) If you have problems loading some specific RTF file, please send this file to me by e-mail

2) Item text cannot contain line break characters and tabs.
AddTextNLA may add several items. #13#10 separates items, tabs are added as a special item (TRVTabItemInfo).
Solutions:
a) you can clear the cell and recreate it using AddTextNLA methods.
b) use undocumented methods. For example you can see this demo: http://www.trichview.com/support/files/mailmerge3.zip (mail merging where field values can be multiline text; without tabs, though)
Post Reply