Dependency error in jasper-reports from itext

A much simpler solution may be to upgrade to a newer version of jasperreports. Version 6.1.0 has this dependency on iText: <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>2.1.7.js2</version> <scope>compile</scope> </dependency> No more “floating” dependency on iText, and it’s a version that’s custom made for jasperreports! See http://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports/6.1.0 for the complete pom.xml.

JasperReport – wrap text to show long text in textfield

I found the answer myself : I did some extra research about the properties of textField and rectangle components. And found that I need to set the following properties. For rectangle : <rectangle> <reportElement stretchType=”RelativeToBandHeight” … /> </rectangle> For textField : <textField isStretchWithOverflow=”true”> … </textField> Output as expected : The <detail> …</detail> section after correction … Read more

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

PDF Generation Library for Java [closed]

Give JasperReports a try. Use iReport to create the .jrxml files. JapserReports can handle complex layouts. For those parts of the report based on different queries have a look at using subreports embedded into the main report. Just like @Adrian Smith’s solution this approach will separate the report layout editing from the data sourcing.

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