How do I change the locale that JasperReports uses?

The locale is set during execution, not in the JRXML. Using Java, set the REPORT_LOCALE parameter for the report’s parameter map. For example: InputStream reportTemplate = getReportTemplate(); JRDataSource dataSource = getDataSource(); java.util.Map parameters = getParameters(); java.util.Locale locale = new Locale( “en”, “US” ); parameters.put( JRParameter.REPORT_LOCALE, locale ); JasperFillManager.fillReport( reportTemplate, parameters, dataSource ); Using Jaspersoft Studio, … Read more

How to use JasperReports with Spring MVC?

Based on my research, I’ve found the following usage methods. The methods begin with the most direct (naive) approach involving less up front complexity / configuration and evolve to become more abstract but with more dependencies on Spring / more complex Spring configuration. Method 1: Use the JasperReports API directly in the Controller Just write … Read more

How to pass main report data source to subreport (JasperReports)?

You can pass datasource via the built-in REPORT_DATA_SOURCE parameter. The example: <subreport> <reportElement x=”261″ y=”25″ width=”200″ height=”100″/> <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression> <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + “subreport.jasper”]]></subreportExpression> </subreport> You can create new instance of datasource based on variable, parameter or field. The sample: <variable name=”HeadingsCollection” class=”java.util.Collection” calculation=”System”> <initialValueExpression><![CDATA[new java.util.ArrayList()]]></initialValueExpression> </variable> … <subreport> <reportElement x=”0″ y=”0″ width=”515″ height=”20″/> <subreportParameter name=”ReportTitle”> <subreportParameterExpression><![CDATA[$P{ReportTitle}]]></subreportParameterExpression> </subreportParameter> … Read more

JasperReports 5.6: JRXlsExporter.setParameter is deprecated

JRExporter became deprecated in 5.6. They introduced new interface Exporter and retrofitted all exporters to have ExporterInput, ReportExportConfiguration, ExporterConfiguration,ExporterOutput. See below link http://jasperreports.sourceforge.net/api/net/sf/jasperreports/export/Exporter.html This means that instead of setParameter, you need to create configuration using above mentioned classes or their child classes PDF export example. Excel export should follow same methodology JRPdfExporter exporter = new … Read more

Multiple queries in a single jasper document

It is possible to use execute multiple queries from a single report by using a subDataset and datasetRun. The behaviour is like having one or more subreports embedded into a single report file. Define a subDataset like this: <subDataset name=”dataset1″> <parameter name=”someParam” class=”java.lang.String”/> <queryString><![CDATA[SELECT column1, column2 FROM table1 WHERE column1=$P!{someParam}]]></queryString> <field name=”column1″ class=”java.lang.String”/> <field name=”column2″ … Read more

Why do I get compilation error “org/codehaus/groovy/control/CompilationFailedException”?

You will have to set the language value in your template to Java. There are two ways you can do this: If you are using iReport, select the root object in your Report Inspector (the one with the same name as your report). Then in the Properties window, select Java from the Languages drop-down. If … Read more

How do I compile jrxml to get jasper?

There are three ways to compile jrxml to jasper. You can do direct compile via compile button (hammer logo) on iReport designer. You can use ant to compile as shown in the Ant Compile Sample. <target name=”compile1″> <mkdir dir=”./build/reports”/> <jrc srcdir=”./reports” destdir=”./build/reports” tempdir=”./build/reports” keepjava=”true” xmlvalidation=”true”> <classpath refid=”runClasspath”/> <include name=”**/*.jrxml”/> </jrc> </target> Below is the report … Read more

Font is not available to the JVM with Jasper Reports

I tried installing mscorefonts, but the package was installed and up-to-date. sudo apt-get update sudo apt-get install ttf-mscorefonts-installer I tried searching for the font in the filesystem, with: ls /usr/share/fonts/truetype/msttcorefonts/ This folder just had the README, with the correct instructions on how to install. cat /usr/share/fonts/truetype/msttcorefonts/README You need an internet connection for this: sudo apt-get … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)