Jump to content
We've recently updated our Privacy Statement, available here ×

How to create a table from csv data?


glen.farrelly

Recommended Posts

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.

 

Thanks

 

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

..insert your code herepublic 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");        try        {            _jasperReport = JasperCompileManager.compileReport(pathReportJasper);            writeInfoLog("OPS: Report Configuration "+pathReportJasper+" has been prepared");        }        catch (Exception e)        {            putKOReport(outputStreamEnvelopeFactory,e.toString().getBytes());;            e.printStackTrace();            writeErrorLog("OPS: prepareReport " + e.getMessage() + " " + e);            throw new RuntimeException(e);        }    }..[/code]

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?

Link to comment
Share on other sites

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.

 

 

 

 

 

Link to comment
Share on other sites

In Jaspersoft Studio, I have only a main report...it 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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...