Skip to Content
0

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

Apr 26 at 07:15 AM

36

avatar image
Former Member

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Abhilash Kumar
Apr 26 at 12:00 PM
1

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
Abhilash Kumar
Apr 26 at 08:06 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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?

0
Abhilash Kumar
Apr 26 at 01:24 PM
0

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

Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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
Former Member

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

0

Hi Shahabas,

<br> should work.

You're missing the </br> tag.

-Abhilash

0
Former Member
Abhilash Kumar

For intention?

0