Skip to Content
avatar image
Former Member

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

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Apr 26 at 12:00 PM

    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

    Add comment
    10|10000 characters needed 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

  • Apr 26 at 08:06 AM

    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

    Add comment
    10|10000 characters needed 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?

  • Apr 26 at 01:24 PM

    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

    Add comment
    10|10000 characters needed characters exceeded