Table to Text Column Alignment

General TRichView support forum. Please post your questions here
Post Reply
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Table to Text Column Alignment

Post by gdenny »

Hello. I have implemented your example of converting all tables in a richviewedit to text in BCB2007. I have replaced your ; column delimiter with a tab using rv->AddTab instead of rv->AddNLATag in the example. It works great except that the columns do not align once converted to text. The table will look similar to

HISTOLOGIC TYPE: Superficial spreading
SURGICAL MARGIN STATUS: Positive, peripheal
TNM CODE: pT1a pNX

while the text conversion will look similar to

HISTOLOGIC TYPE: Superficial spreading
SURGICAL MARGIN STATUS: Positive, peripheal
TNM CODE: pT1a pNX

Is there some way to align the columns of the text conversion using tabs when the text contents of the table cells vary in length as they do in this table?

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, no.
You need to write your own text export procedure to implement this feature.
It is not in our plans, sorry.
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

That is OK. Can you tell me the functions to use to access the text inside of a table cell so that I can check it's length to customize how many tabs or spaces to add? Thanks.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The simplest way is GetRVDataText(Cell.GetRVData).
GetRVDataText is defined in RVGetText.pas (AnsiString version) or RVGetTextW.pas (Unicode version)
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

Thanks. I ended up using rv->GetItemText(rv->ItemCount-1) to get the contents of the cell and getting the contents.Length() to determine how many tabs to add. This method works only for fixed fonts like courier new, however. Contents.Length() just returns the number of characters in the cell and does not account for them being different widths, as is the case for proportional fonts. Are there functions other than Length() that would work better with proportional fonts? Failing that, how would I set only the table style to a fixed font. Currently, I am using

for (i = 0; i<rv->Style->TextStyles->Count; i++)
rv->Style->TextStyles->Items->FontName = "Courier New";

but it sets the entire richedit and not just the tables inside.

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) I still recommend using GetRVDataText.
Yes, you can write a function for getting text from individual items, but the method you described works only for text items (GetItemStyle()>=0)

2) Yes, I think you should use a fixed font.
How do you insert text?
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

The text is inserted into the tables from a word processor as a proportional font. It looks
good on printouts but I am needing to convert it to a pdf using a Rave report and the table is not rendering properly (it only showsWidth1Width0Width0, etc). It is not really a RichView problem at all but a Rave issue. While I have had some success with the fixed font replacement, it is really not the solution I need and am now looking at a different approach to creating a pdf using print drivers (currently pdfcreator). Thanks for all of your help and for a great product.
Post Reply