How to create a table from csv data?

Hi guys,

I've created a data adapter and can preview all my CSV data but when I add the table and set its dataset to this, it's always blank. 

Can anyone simply explain how to get csv shown in a table. I can get the data displayed when I'm creating a simple report but not a table.




glen.farrelly's picture
Joined: Sep 23 2019 - 3:23pm
Last seen: 2 years 6 months ago

4 Answers:

This can be achieved if you pass the $P{REPORT_DATA_SOURCE} to the table in the "Use a JRDataSource Expression". See file image.. 

Also need to pass the $P{REPORT_PARAMETERS_MAP} to the table's parameters map. 

Image icon tableexpression.jpg39.61 KB
vchiem's picture
Joined: May 1 2017 - 5:33pm
Last seen: 15 hours 50 min ago
..insert your code here
public void prepareReport() throws SQLException, OutputNotFoundException, OutputEnvelopeCreationException
        _parameters.put("PARAM1", "/main/prj/xxx1.png");
        _parameters.put("PARAM2", "/main/prj/xxx2.jpg");
        _parameters.put("PARAM3", "/main/prj/xxx3.jpg");
        _parameters.put("PARAM4", "/main/prj/xxx4.jpg");
            _jasperReport = JasperCompileManager.compileReport(pathReportJasper);
            writeInfoLog("OPS: Report Configuration "+pathReportJasper+" has been prepared");
        catch (Exception e)
            writeErrorLog("OPS: prepareReport " + e.getMessage() + " " + e);
            throw new RuntimeException(e);

Hi, I did the same thing! In Jaspersoft Studio I can see the table with data!! But, when I launch myReport from my java application all tables are empy. Why is this happaning? Any Idea? For istance, I put here my prepareReport()...have I to set REPORT_PARAMETER_MAP? How?

emanuele.a89's picture
Joined: Dec 12 2017 - 8:49am
Last seen: 1 year 5 months ago

Thanks to VCheim's suggestion I was able to acheive my goal. Where is what I did:

  • Create the main report
  • Connect the main report to the data adapter you want to use to fill the table. In my case, it's a csv data file. Choose csv as the language, and click "read fields" to get the fields created automatically. Now your main report has access to all these fields.
  • Drag a table into the detail band. Choosing new dataset is fine at this point and clicking finish. This will just create a name for the table's dataset but not set any values.

At the moment there are two datasets. The main report's, which doesn't have a name, and the table's, which by default is called Dataset1. 

Now, we need to "send" the dataset of the main report to the table, by following the suggestion, that is:

  1. From the main report, click the table and select the Dataset tab.Select JRDatasource expression, and enter this expression: $P{REPORT_DATA_SOURCE}
  2. The final step is to make sure your Dataset1 has the same field names and types as your main report's. (From some experimenting I found that it doesn't matter what dataadapter you set to Dataset1 or what language - none of this is taken into account once we tell the table to read the report's data source.)

All set to go now, just drag your fields into the detail row of the table, click preview to see that the table is showing the data.






glen.farrelly's picture
Joined: Sep 23 2019 - 3:23pm
Last seen: 2 years 6 months ago

In Jaspersoft Studio, I have only a main is just one page! And I use $P{REPORT_PARAMETER_MAP} for the table's dataset1, in order to show the data! The Jasper it is ok!! My problem now it is the java code....I don't know how to pass $P{REPORT_PARAMETER_MAP}....or if I have to do something different. If I launch myJavaCode with the report's paramaters I have defined I get a page with all the data, but withouth tables...How can I solve this?? I posted above my java code.

emanuele.a89's picture
Joined: Dec 12 2017 - 8:49am
Last seen: 1 year 5 months ago