Page 1 of 1

Table to Text Column Alignment

Posted: Mon Oct 28, 2013 9:54 pm
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.

Posted: Tue Oct 29, 2013 8:37 am
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.

Posted: Tue Oct 29, 2013 3:03 pm
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.

Posted: Thu Oct 31, 2013 7:00 am
by Sergey Tkachenko
The simplest way is GetRVDataText(Cell.GetRVData).
GetRVDataText is defined in RVGetText.pas (AnsiString version) or RVGetTextW.pas (Unicode version)

Posted: Sun Nov 03, 2013 4:54 pm
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.

Posted: Sun Nov 03, 2013 7:11 pm
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?

Posted: Wed Nov 06, 2013 4:15 pm
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.