Report details are not displayed

1

I made a report in Jasper Studio 5.6.0, and I imported my generated * .jrxml file into the IDE where I am developing, but anything that is placed in the Details section of the report simply does not appears, even though it is only a simple and fixed text is blank, but in preview of jasper studio it appears normally I configured the report:

Ihavenoideawhatmightbecausingthis,forexample,ifIputthecontentinthe"Title" tab everything is displayed correctly.

    
asked by anonymous 04.08.2017 / 19:17

1 answer

2

I'll show you how to build a JasperReports report from scratch, since you do not know exactly what the problem is.

No JasperReport Studio 5.6.0:

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

InthisexampleIwillusetheDatabaseJDBCConnection,butherethedeveloperchoosesandfillsinthedata.Youshouldtesttheconnectionandseeif"Sucessful" returns.

Next you go into the DataSet and Query editor dialog:

SelectyourDataAdapterintheupperleftcornerandpasteyourqueryontherightside.Seeifallthefieldsappearinthemenubelow(Normallyitisautomatic).Thiswillbeinthe"Fields" tab.

Returningtothedesignofyourreport(Figure2),inthe"Detail" section, the fields that are to be received from the DB must be placed in a TextField and its expression should have the following format: $F{nomedocampo} (Figure 4 - Right side), the tag $P{nomedocampo} for parameters. The parameters must be placed by the developer before the report is generated (including in the preview). To create a new parameter go to the "Outline (bottom left field) > Parameters > Create parameter" menu. (Figure 4 - Left side)

Byclicking"Preview" to verify that everything is displayed properly your .jasper file will be generated automatically.

In 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
    
07.08.2017 / 17:11