Print Page | Close Window

formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1931
Printed Date: 06 May 2024 at 12:08pm


Topic: formula
Posted By: rptxyz
Subject: formula
Date Posted: 24 Dec 2007 at 7:56am
text1          text2
text3aaa    text4
if concatening four or more words into two columns and like to make sure column2 texts are lined up. is there any way?.



Replies:
Posted By: rptxyz
Date Posted: 24 Dec 2007 at 8:17pm

in crystal report 9 i try to put the array of strings into a format but they do not line up neatly.
Local NumberVar d;
Local StringVar array MyArr;
Local NumberVar i;
Local StringVar MyStrLine;
Local StringVar MyStr;
MyStr := "BBBBBBBB-CCCCCCC-DDDD-DDDDAA-AA-DDDDAA-AAA-IIII-LLLLL-NNNNN-YYYYY";
MyArr := Split(MyStr, chr(45));
MyStrLine := trim("");
 
For i := 1 To (UBound(MyArr)) do
(
    MyStrLine := MyStrLine & MyArr;

    if (Remainder(i, 4) = 0) then
    (
        MyStrLine := MyStrLine & chr(10);
    )
    else
    (
        for d := 1 to (15 - Length(MyArr)) do
        (
           MyStrLine := MyStrLine & chr(32)
        );
        MyStrLine
    );
);

MyStrLine

result should line up:
BBBBBBBB    CCCCCCC   DDDD    DDDDAA
AA           DDDDAA     AAA      IIII
LLLLL         NNNNN      YYYYY

        



Posted By: BrianBischof
Date Posted: 24 Dec 2007 at 9:52pm
What font are you using? Most fonts are variable width for each type of character. Try using the Courier font and see if this fixes your problem.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: rptxyz
Date Posted: 24 Dec 2007 at 11:03pm
thank you. that was it.


Posted By: tconway
Date Posted: 26 Dec 2007 at 10:06am
If you need to use a standard font, such as Arial, another possibility to this is to put the formula in a text box with the correct number of tab stop settings on the text box rather than the string.  Then, instead counting the number of spaces required, insert only a single tab to each break in the string. 
 
For i := 1 To (UBound(MyArr)) do
(
    MyStrLine := MyStrLine & MyArr;
    if (Remainder(i, 4) = 0) then
    (
        MyStrLine := MyStrLine & chr(10);
    )
    else
    (
        MyStrLine := MyStrLine & chr(9)
    );
);
MyStrLine
 
To get this to work properly I had to
1.  Add an empty Text Box
2.  Insert the formula field in it.
3.  Highlight the field and, while the field was highlighted and the textbox in edit mode...
4.  Put tab stops in the correct locations.
 
With the sample above I used 1.25, 2.5 and 3.75.
 
If you have a huge amount of data going in, this may not be best, but it might be worth a try.
 
Tim
 
 



Print Page | Close Window