Escape dollar ($) sign in jasper report

I would like to know if there is a way to escape dollar ($) sign in JasperReport (I'am using Dynamic Jasper) I tried the unicode and xml escape but it doesn't work.

I get this error :

1. Syntax error on token "$F", { expected
            value = $F{$}; //$JR_EXPR_ID=13$

The Dynamic Jasper Report Code is :

        .setTitleStyle(titleStyle).setTitleHeight(new Integer(30))
        .setSubtitleHeight(new Integer(20))
        .setDetailHeight(new Integer(8))//defines the height for each record of the report
        .setMargins(margin, margin, margin, margin)
        .setDefaultStyles(titleStyle, null, headerStyle, columDetail)
        .setColumnsPerPage(new Integer(1))//defines columns per page (like in the telephone guide)
        .setColumnSpace(new Integer(5))
        .setWhenNoData(SwtConstants.DYNAMIC_JASPER_NO_DATA_FOUND, null,true,true)
        .setQuery(queryResult.getExecutedQuery(), DJConstants.QUERY_LANGUAGE_SQL);

as you see i'm using "setQuery" I have the list of columns saved in a object, so I browse the list to create the columns using this code :

// Varchar columns will not be styled
                abstractColumn = ColumnBuilder.getNew()
                        .setColumnProperty(columns.get(i).getColumnLabel(), String.class.getName())

if you want to reproduce this error just type a query like :

Select '$' from dual

Please note that the same error occur with "}" char too.

Can anyone help me please ?


I found way to resolve this issue, it's a bug in Dynamic Jasper I think because Jasper need to name the field exactly as the column name and use this field as the TextExpression.

So to avoid doing this we need to override this function and using customExpression so the code need to be changed to this :

                    abstractColumn = ColumnBuilder.getNew()
                        .setColumnProperty(columns.get(i).getColumnLabel(), String.class.getName())
                        .setCustomExpression(new CustomExpression() {
                            public Object evaluate(Map fields, Map variables,   Map parameters) {
                                return (String) fields.get(columnName);

                            public String getClassName() {
                                return String.class.getName();

This will resolve the problem for all the special chars. I will show you how the JRXML file will look as if we made this modification just to understand the concept :

It will be changed from :



<textFieldExpression><![CDATA[(($P{REPORT_PARAMETERS_MAP}.get("customExpression_for_DJR_3068_COLUMN_1")).evaluate( (($P{REPORT_SCRIPTLET}).getCurrentFiels(), (($P{REPORT_SCRIPTLET}).getCurrentVariables(), (($P{REPORT_SCRIPTLET}).getCurrentParams() )]]></textFieldExpression>

Hope this will help someone :)

Need Your Help

Web App Libraries empty in Eclipse - no "jars" found

java eclipse spring jar

Recently my Spring MVC Java app, developed in Eclipse Indigo, seemed to lose it's connection to my "lib" folder where all my jars are (there were no jars found for my project anymore).

IIS app pool recycle + quartz scheduling

c# iis

I'm running a web app on IIS 7.5 and it needs to recycle occasionally (otherwise memory usage gets out of handing, something i'm looking into!).