cancel
Showing results for 
Search instead for 
Did you mean: 

how to split and change the font style of a crystal report element?

0 Kudos

we are having a report generated using crystal report While generating we have a request to have a checkbox with a list of items. The checkbox is only available in the Wingdings font. Since we are using Arial font for the list items we can not change the font of the formula field through which we are showing the list. Eg: [] task1 [x] task2

we need to split each list item and replace the square brackets with checkbox form the wingdings font.

how can we create a formula for this in crystal report?

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor

Hi Shahabas,

1. Create a formula with this code:

local stringvar s := {string field}; //Replace this field with the actual database field
local stringvar array s2 := split(s,"|");
local stringvar fs;
local numbervar i;
for i := 1 to ubound(s2) do
(
    if s2[i] like '[x*' then
        fs := fs & '<font face = "wingdings">'&chr(254)&'</font>' & ' ' & '<font face = "arial">' & Mid(s2[i],instr(s2[i],"]")+1) & '</font>' 
    else if s2[i] like '[]*' then
        fs := fs & '<font face = "wingdings">'&chr(111)&'</font>' & ' ' & '<font face = "arial">' & Mid(s2[i],instr(s2[i],"]")+1) & '</font>' 
);
fs;

2. Drag and drop this field on the report > right-click the field > Format Field > Paragraph tab > Under "Text Interpretation" select "HTML Text".

-Abhilash

0 Kudos

hi thanks for the reply but the HTML is rendering as the text itself. Even if the Text Interpretation is HTML Text

Answers (2)

Answers (2)

abhilash_kumar
Active Contributor
0 Kudos

What version of Crystal Reports do you use?

Does it work if you were to replace {string field} with a sample text:

local stringvar s := '[]task1|[]task2|[x]task3';

-Abhilash

0 Kudos

I tried it another way and it worked. sorry for the last comment it was my mistake.

But the issue now is that I had intention applied for this field. that does not work now.

I have to display the task in a cell so I had to can grow it.

I need to intent it like,

[] my task

__is to do this(space)

instead of

[] my task

is to do this

stringvar MYARRAY:= Replace ({Notes1},"[]" ,'<font face = "wingdings">'&chr(254)&'</font>');
stringVar  MYARRAY1 := ' '+Replace (MYARRAY,"|" ,'<br>');
MYARRAY1;


<br>
0 Kudos

I guess it because the formula field is type html is there any way around for this

abhilash_kumar
Active Contributor
0 Kudos

Hi Shahabas,

<br> should work.

You're missing the </br> tag.

-Abhilash

0 Kudos

For intention?

abhilash_kumar
Active Contributor
0 Kudos

Hi Shahabas,

Create a separate formula with the checkbox character - chr(254) and chr(111).

Apply wingdings font on this formula and place it beside the Item field.

-Abhilash

0 Kudos

Hi Abhilash,

I cannot do that because I'm actually getting it as a concatenated string with is separated by a pipe symbol. I replace the pipe symbol with space and return so that it showed a list.

Eg:

we get the string like, []task1|[]task2|[x]task3 I need to get this square brackets replaced with the wingdings checkbox.

is there any way that we can add a formula to the font by splitting?