Jaspersoft Interview Questions

Q. Explain what is Jasper Reports?
Jasper Reports is used to Generate the reports from the Database. A powerful report-generating tool that has the ability to deliver rich content onto the screen, to the printer or into PDF, HTML, XLS, CSV and XML files.

Q. What do you understand by JRXML?
JasperReports reports are defined in an XML file format, called JRXML, which can be hand-coded, generated, or designed using a tool. The file format is defined by a Document Type Definition (DTD) or XML schema for newer versions, providing limited interoperability.

Q. How to set dynamic main report width when using crosstab?
Ans: For a single crosstab use the attribute ignoreWidth=”true”

Q. How to create crosstab derived measure?
Cross tab fills the data at the time of report execution. So it is not possible to find more calculations on already calculated on filled values rather you need to define the Type01/Type02 with in your SQL query so that you can another measure.

Q. Main features of JasperReports?

  • Some of the main JasperReport features include:
  • Has flexible report layout.
  • Multiple ways to present data, it can present data textually or graphically.
  • JasperReports can generate watermarks.
  • Developers can supply data in multiple ways.
  • JasperReports can generate subreports.
  • JasperReports can accept data from multiple datasources.
  • JasperReports is capable of exporting reports to a variety of formats.

Q. What do you understand by Multiple ways to supply data feature, Can you explain?

JasperReports allows developers to pass data to a report through the report parameters, Report parameters can be instances of any Java class. Data can also be passed to a report by using special classes called datasources. Report parameters and datasrouces can be combined to maximum flexibility.

Q. Name any three main Jasper Managers classes?

  • net.sf.jasperreports.engine.JasperCompileManager: Used to compile a JRXML report template.
  • net.sf.jasperreports.engine.JasperFillManager: Used to fill a report with data from a datasource
  • net.sf.jasperreports.engine.JasperPrintManager: Used to print the documents generated by the JasperReports library

Q. How to save the compiled JasperReport as a .jasper in a file?
You can use following method: JasperCompileManager.compileReportToFile(“C:\\xxx.jrxml”, “C:\\xxx.jasper”);

Q. What is the difference between ireport and jasperreport?
iReport is a graphical report designer tool that uses JasperReports API. Designing the reports become easy if we use iReport.
JasperReports API is the build that was/is being released by Jasper Team(JasperSoft) that provide necessary jar files that are helpfull in creating reports.

Q. What is Jaspersoft OLAP?
In general, Jaspersoft OLAP refers to the Business Analysis capability found in JasperReports Server. Business Analysis is also known as OnLine Analytical Processing (OLAP), and is enabled via the Open Source projects Mondrian and JPivot.

Q. What is JasperReports Server?
Typically, JasperReports Server refers to both the core server functionality (creating and managing users and roles, assigning permissions, scheduling reports, etc) and to the Business Reporting functionality which is enabled by JasperReports.

Q. How to pass a parameter list for the same field in the prompt iReport?
Create a parameter and precede the parameter of the SQL query of the report by one! . To run the report, enter prompt in the desired parameters separated by commas to respect SQL syntax. Example:
sql code:
SELECT * FROM myTable WHERE mycode IN ( $ P! { MonParametre } )

Q. How do you limit the number of rows on each page in JasperReport?
If you want to display max number of rows in each page to 5, then you can use
$V{REPORT_COUNT} % 5 == 0

Q. How to change date format (month name) in iReport?
To display dates in different formats, one option is to format dates based on locales. For example, the following expression uses the current user’s locale:
DateFormat.getDateInstance(DateFormat.LONG, $P{REPORT_LOCALE}).format($F{currentDate})

Q. Write a sample code to show an image on jasper report?
<imageExpression class=”java.lang.String”>
<![CDATA[$P{REPORTS_DIR} + “/images/logo.jpg”]]>

Q. How to display date in HH:mm:ss format in JasperReports?
You can use following code in Java:
new SimpleDateFormat(“MM-dd-yyyy HH:mm:ss z”).format($V{VAR_DATE})
where $V{VAR_DATE} is the date variable to be converted into the format.

Q. What is the difference between .jasper, .jrprint, .jrpxml, .jrxml JasperReport file formats?

  • .jrxml is a human readable XML file that contains the report template i.e. report structure and its formatting rules.
  • .jasper is the compiled report template i.e. compiled .jrxml file. You use this file as the template argument in the JasperReports API.
  • .jrprint is a serialized JasperPrint object i.e. an actual report instance i.e. a template that has been filled with data. This file can be deserialized back into a JasperPrint object.
  • .jrpxml is a human readable XML represenatation of a JasperPrint object i.e. an XML version of a template that has been filled with data. This file can be unmarshalled back into a JasperPrint object.

Q. What is the difference between variable, parameter and field in Jaspersoft iReport Designer?

  • Parameters are simple input to JasperReports. You have to define parameters in the JasperReport before using them. You can display the value of the variable, you can use it as part of boolean expressions and you can even pass it to subreports. This can be an input to SQL query.
  • Fields are simple variable definitions. You can think of these as instance variables of the datasource object thats passed in to the report or they can be key names if the datasource is a Map. If you configure JasperReport to create the dataset based on SQL, then Fields are the column names of the ResultSet. You will use Fields to display the resultset of an executed SQL query.
  • Variables are another kind of variables that live within Jasper Report, they are not inputs. They are used to calculate sum or average of certain Field (defined above). You can perform many other predefined calculation functions on the Fields using Variables.

Q. How you will avoid null values in jasper reports?

By set the property isBlankWhenNull to true.
In iReport check the Blank When Null checkbox when your field is selected.
In jasper jrxml file: <textField isBlankWhenNull=”true”>

Q. What are the drawbacks with Jasper Reports?

Q. What is the advantage of using IReport/JasperSoft Studio in desigining reports? What’s the disadvantage

Allows those without a technical java background to quickly and easily design reports, drawback is that jrxml templates are static and allow for little dynamic/on the fly changes to report content

Q. What is the advantage of using pure Java (no jrxml) in designing reports?

Allows greater control of how the report is generated, allows for dynamic report content/disadvantage is that it requires a solid understanding of Java programming and requires greater trial and error to achieve the desired layout (there is no preview mode)

Q. What options are available to developers for integrating Jasper Reprots into an existing web application?

The spring framework has support for running/intregrating reports in ain existing java web app, Maven has a plug in that will compile jrxml templates into java bytecode that can be packaged just like any other java program into a war/ear file; Jasper provides a SOAP API, a REST API, and now a VIsualize.js javascript framework for integration of a JasperServer installation into an existing java web application (these provide a bridge between a java app and JasperServer)

Q. Does JasperSoft provide a method to version reports/report templates?

No, not out of the box. Jrxml and Java classes used in reports design/generation must be versioned using SVN, Hg, etc.

Q. When does it make sense to use a subreport?

When the result set of another query is required in the same report; Jasper is intended to use one query per report, with the exception of subdata sets (research this on your own); also, if a report that contains a query can be reused in other reports, it makes sense to package it as a subreport, this avoids code duplication

Q. Why wouid we use a subreport vs a sub dataset?

when a return value is required; only subreports can return a value; when the code can be used in multiple places; subreports are themselves fully fledged reprots that can be used independently or within other reports

Q. How are values passed to reports at runtime?

via parameters

Q. Can multiple data sources be used in the same report?

yes it is possible, but not recommended; everything but the main report connection must be defined within a parameter, and unless JNDI name spaces are configured for the various data sources, usernames and passwords must be stored within the JRXML itself; which for various reasons is not good design practice. Jasper is intended to use one datasource per report

Q. Can the same jrxml template be used to properly export to various output formats?

yes, the same template can be used to export to a variety of output formats, but compromises must be made; for example a template optimized for export to PDF may not result in the best looking/fucntioning excel spreadsheet; in such cases each ouitput format would require a dedicated jrxml template

Q. Can jasper reports include images that are generated dynamically at runtime?

Yes, Jasper can generate images using the JRRenderable class, where parameters can be based, the image generated, and then included in the report. See an example here:

For more  Click Here