Report details are not displayed

Asked

Viewed 981 times

1

I set up a report in Jasper Studio 5.6.0, and imported my generated *.jrxml file to the IDE where I am developing, but everything that is put in the session "Details" the report simply does not appear, even if it is only a simple and fixed text it is blank, but in "preview" from Jasper studio it usually appears so configured the report:

inserir a descrição da imagem aqui

I have no idea what might be causing this, for example, if I put the content in the tab "Title" everything is displayed correctly.

  • Before answering clarify a few things: what do you want in Details comes from a query? What is your datasource?

  • I tried it with querys (and when I tested it in the preview of Jasperstudio it showed right) and tried to put a Static Text (which in the preview also worked) but when I will generate the report, the PDF file displays everything but the contents of the Tails tab

1 answer

2


I’ll show you how to build a Jasperreports report from scratch, since you don’t know exactly what the problem is.

In Jasperreport Studio 5.6.0:

First thing is to set the Data Adapter by clicking on "Data Adapters > Create New Data Adapter"

Figura 1 - Data Adapters

In this example I will use the Database JDBC Connection, but then the developer chooses and populates the data. You must test the connection and see if it returns "Sucessful".

Next you go to the Dataset and Query editor dialog:

Figura 2 - DataSet and Query Editor dialog

Select your Data Adapter in the upper left corner and paste your query in the right side. See if all fields appear in the menu below (Usually it is automatic). This will be in the "Fields tab".

Figura 3 - Query Editor

Returning to the design of your report (figure 2), in the "Detail" section, the fields that will be received from DB should be placed in a Textfield and its expression should have the following format: $F{nomedocampo} (Figure 4 - Right side), being the tag $P{nomedocampo} for parameters. The parameters must be placed by the developer before the report generation (including the preview). To create a new parameter go to the "Outline (lower left field) > Parameters > Create Parameter" menu. (Figure 4 - Left side)

Figura 4 - Parâmetros à esquerda e Expressão à direita

By clicking "Preview" to check that everything is correctly displayed your file . Jasper will be generated automatically.

In the Java code:

// Gerando um relatório com parâmetros
HashMap params = new HashMap<>();
params.put("nomeParametro", inputDoParametro);

URL arquivo = getClass().getResource("/com/seuprograma/seupackage/relatorio.jasper");
JasperReport jreport = (JasperReport) JRLoader.loadObject(arquivo);
JasperPrint jprint = JasperFillManager.fillReport(jreport, params, JDBCconnection);

// Gerando o pdf
JasperExportManager.exportReportToPdfFile(jprint, file.getPath());

Report without parameters:

URL arquivo = getClass().getResource("/com/seuprograma/seupackage/relatorio.jasper");
JasperReport jreport = (JasperReport) JRLoader.loadObject(arquivo);
JasperPrint jprint = JasperFillManager.fillReport(jreport, null, JDBCconnection);

// Gerando o pdf
JasperExportManager.exportReportToPdfFile(jprint, file.getPath());

This procedure was tested with an SQLITE database, using JDBC sqlite-jdbc-3.19. 3, java 8 and jasperstudio 5.6.0/ireports 5.6.0. Libs used:

commons-beanutils-1.9.3.jar
commons-collections-3.2.2.jar
commons-digester-2.1.jar
commons-javaflow-20160505.jar
commons-logging-1.1.1.jar
itext-2.1.7.js6.jar
jasperreports-6.4.1.jar
  • Thank you very much for your reply, it worked as I needed it

  • will you be able to help in this, sometimes when I run my process at the time of generating the report the following error is displayed in the logs: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '&#xA; net/sf/jasperreports/fonts/pictonic/pictonic.ttf&#xA; net/sf/jasperreports/fonts/pictonic/pictonic.svg&#xA; net/sf/jasperreports/fonts/pictonic/pictonic.eot&#xA; net/sf/jasperreports/fonts/pictonic/pictonic.woff&#xA; ' is not available to the JVM. See the Javadoc for more details. But sometimes it just works normally

  • 1

    When using a non-standard font Jasperreports recommends that you add a Font Extension, basically put that font into a .jar. More information here: http://community.jaspersoft.com/wiki/custom-font-extension

  • But I am using the Arial font, this would not be necessary to add as it is a native source right?

  • I even tried to add the Arial source file to the Jasper project but still the same error was accused< there is something I need to do after that?

  • Could you post this in another question? Because I would need to see your jrxml code. That way other people would benefit from a possible solution.

  • I found out what it was, I had two *.jar (Jasperreport 5.1.0 | 5.6.0) together and I found in a forum that this can be caused by this https://stackoverflow.com/questions/20795447/jasper-reports-font-error

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.