Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert a line break in a StringVar in Crystal Reports

How do I enter a line break (or other non-text characters usually solved with escape characters) in a StringVar in Crystal Reports?

Wanted output:

line 1
line 2

I've tried StringVar s := "line 1 \n line 2";, but that does not work.

like image 848
LapplandsCohan Avatar asked Aug 29 '12 11:08

LapplandsCohan


People also ask

How do you add a line break in Crystal Reports?

If you need to add a line break in a formula field just use the ChrW function which “returns the single character text string associated with the Unicode value passed in” with the value of 13. The Unicode value associated with 13 is the carriage return. "This formula field " + ChrW(13) + " contains a line break!"

How do I insert a dotted line in Crystal?

You can also select this option from the Format menu. Use the Format Line tab to set the formatting specification for a line in the report. This list shows all the available styles for the line, such as: Single, Dashed, Dotted, and so on. Click the button that represents the line width you want to use.

What is CHR 13 in Crystal Reports?

Chr(10) is the Line Feed character and Chr(13) is the Carriage Return character.


2 Answers

i have simply used following code for line break

"This formula field " + ChrW(13) + " contains a line break!"

like image 54
Pranjal Jain Avatar answered Oct 21 '22 04:10

Pranjal Jain


It may not be much of an improvement, but you could build a string-formatting, custom function:

// sf()
Function (Stringvar text)

    Stringvar Array keys := ["\n"];
    Stringvar Array values := [Chr(10)+Chr(13)];

    Numbervar i;

    For i := 1 to Ubound(keys) do (
        text := Replace(text, keys[i], values[i])
    );

    text;

//{@ text}
sf("line 1 \n line 2")

This would offer you some extensibility should you need to support additional escape sequences.

like image 30
craig Avatar answered Oct 21 '22 05:10

craig