Search code examples
htmlmysqlcrystal-reportscrystal-reports-2013

HTML tags to highlight data in MYSQL and Crystal Reports


This may be a duplicate but from what i have found i think it is slightly different. Also didnt want to comment or add answers to articles already marked as "Answered"

I have a query that i have used in a Crystal Report. I have concatenated a few columns together and have made some of them bold in CR easily enough.

However for ease of redevelopment of the Crystal Report (the code wont change much but the design probably will), i have now concatenated several columns and the ones already concatenated above, in to one column.

This creates a blob that i have handle with....

CONVERT(USING UTF8) 

All well and good (sorry, convoluted intro!).

However i am now exploring using HTML tags within the MYSQL query to make things bold and insert spaces, breaks and non-breaked spaces.

The code i tried is below.

CONVERT( 
CONCAT_WS(' ',
        <b>c.codetext</b>,
        m.pcdose,
        SP_GETCODECODE(m.pcunit),
        SP_GETCODECODE(m.pcrout),
        SP_GETCODECODE(m.pcfreqcode),
        m.pcinstruct)USING UTF8) AS 'Drug Info'

From P_DRUGS

I know this doesn't work because i have tried it >:)....and i think it can be done successfully if the concatenated value is text, such as...

CONVERT( 
CONCAT_WS(' ',
        '<b>Paracetamol</b>',
        '500mg',
        'Orally',
        SP_GETCODECODE(m.pcrout),
        SP_GETCODECODE(m.pcfreqcode),
        m.pcinstruct)USING UTF8) AS 'Drug Info'

From Drugs

Can anyone tell me how (or if) you can use HTML tags to do the above and make certain columns bold etc?

Cheers!


Solution

  • Figured this out and it is embarrassing that i missed it before i posted.

    Simply type up the code as you would like it to appear using HTML tags in the MySQL query. As below.

    Select 
    <b>column_name_1</b>, column_name_2
    from table_name
    

    Paste that in to the Crystal Report command and create your report. Then right click on the field that has the HTML on it, click 'Format Field' and under 'Text Interpretation' drop the box down and select 'HTML'

    Painfully easy!

    Hope it helps someone one day anyway!