Vertical text alignment in Crystal Reports?

2019-02-21 09:28发布

In the Crystal Reports editor that comes with Visual Studio (2008) is it possible to align text to the center of a text box rather than to the top?

I can't find the option anywhere and a Google search is not encouraging but I just can't bring myself to believe that they would not include such an obvious feature.

5条回答
我想做一个坏孩纸
2楼-- · 2019-02-21 10:00

I can't find an option to vertically align text within a label, but you can vertically align labels within a section. Use the horizontal guidelines on the left margin to adjust the alignment. You may need to right-click the guideline and un-check "Snap to Grid" to get more precise positioning.

horizontal guideline

查看更多
祖国的老花朵
3楼-- · 2019-02-21 10:02

You can achieve this with strings, as you will see a paragraph tab instead of a number tab when you enter the FORMAT FIELD menu. To make your number a string you should format it as a formula field thusly:

chr(13) + chr(10) + totext(mynumber,0)

Then in the FORMAT FIELD menu select - Line spacing: multiple of: 0.2

You may need to experiment with the 0.2 value until you find your number (i.e. string prefixed with a carriage return) nicely centered in the middle of your box.

Cheers, Chilly

查看更多
Emotional °昔
4楼-- · 2019-02-21 10:05

There is no vertical alignment for crystal reports that I could find. A potential work-around is programming line breaks.

查看更多
神经病院院长
5楼-- · 2019-02-21 10:08

Vertical alignment with programming line breaks. Algorithm for the one cell:

  1. Count the number of characters in data (iTextLen).
  2. Find the number of text lines in cell (iLineNum). Calculated empirically.
  3. Find the row length in characters (iLineLen). Calculated empirically.
  4. Calculate count the number of halfbreaks by formula (iLineNum — 1) — (iTextLen / iLineLen).

    @formula in crystal syntax:

    Local NumberVar iLineNum:= 5;
    Local NumberVar iLineLen:= 30;
    Local NumberVar iTextLen:= Length({DataSource});
    
    Local StringVar sRet:= '';
    Local NumberVar i;
    Local NumberVar iLinesNum:= Truncate(iLineNum - 1) - Truncate(iTextLen / iLineLen); 
    For i:= 1 to iLinesNum Do ( sRet:= sRet + chr(13) );
    
    sRet
    
  5. Add formula to the top and bottom of data. Text objects will look like this:
    {@formula}{DataSource}{@formula}

    Font size of @formula must be halved of font size {DataSource}. For example, if the font size of {DataSource} equal to 20, the @formula should be equal to 10: formula-position-and-font-size

Algorithm works better with monospaced typeface, but with proportional typeface works in most cases.

Algorithm for multiple cells is differ only that iLineNum will be the maximum number of characters in data of all cells.

查看更多
看我几分像从前
6楼-- · 2019-02-21 10:15

in crystal report 10 the label >> right click >> format Text >> Common >> text rotation . choose 90 degree the text will have a vertical alignment same in a field or any object you add to the report hope that i help you

note the answer (Format text > tab Paragraph, Horizontal alignment: Centered) is a wrong

查看更多
登录 后发表回答