JasperReports: dynamic report generation - jasper-reports

I am new to JasperReports. I need to design a report where certain columns and rows are dynamic. For this how I have to design the report and after design i want to integrate with my application for fetching data from action class and dto. How to map data for its?

I don't know how dynamic it will be, but it may help you: http://dynamicjasper.com/
It uses JasperReports to generate your report and it also allow you to create your report on the fly.

There are 2 options to map data with the columns. First option is u can pass ur data into data Source binding with the column name as key value pair. And the second option is u can pass the obj of your dto to data source directly in list form.
Use report.setDataSource() for setting the data. In first option make sure your type of the data matches with the column name.

Related

Use SQL Select directly in CR Function

There's a working report but I wan't to change the visibility of certain rows based on a completely new DB select that should be executed when the report is created.
It would be ideal, if I could load the values of said select in an array or a list and than simply trigger certain row's visibility by comparing e.g. the Row Id with the values in the array.
Im used to solve a problem like this by creating a View that delivers all the essential information in each row and is used as the main data source but I was wondering if there's an elegant way within crystal reports to solve such a task.
I can think of three ways to include control data like this into the report:
One row of config data: If you can arrange it that your config data query returns one row of data, it can be just added to the data sources of the main report, without any links to tables and views already there.
Config resultset for matching: If you have to match main data results to config values row by row, e.g. by the Row Id you mentioned, add this config query to your report and link it to the main data source accordingly. (You are probably already doing this within your pre-created view on database side.)
Query config by subreport: Most flexible but also time consuming option is to add a subreport in report header, add the config data query and arrange config results into (shared) variables as needed in the subreport. Shared variable values can be used in main report then to control section visibility.
Yes, one of the 3rd-party Crystal Reports UFLs (User Function Libraries) listed here provides such a function.

How to relate a column to the row rather than the other way in anylogic

I have created a database in anylogic. Previously, I have related the information in the row to the columnn, i.e. there is a component in the row, and its properties are in the columns, and have put this in a function. Now I want to make the component the column and the properties, but don't know how to make it all relate. Below is the code I've written for the former:
site = selectFrom(parameters) .where(parameters.box_number.eq(boxNumber)) .where(parameters.site.eq(site)) .firstResult(parameters.site);
So box_number is the component and site is one of the properties. With this method, site is a column, but I want it to be a row.
You should use the SELECT WHERE SQL syntax, see https://help.anylogic.com/index.jsp?topic=%2Fcom.anylogic.help%2Fhtml%2Fconnectivity%2Fquerying.html&resultof=%22%73%65%6c%65%63%74%22%20%22%77%68%65%72%65%22%20
You can filter and load data in any format. Also, best use the database query wizard to help:

How to create table using json in birt

i am having one column data as JSON format in table. i want to pass that column as report parameter in BIRT. can anyone help me how to parse JSON data and use it in the report.
One way to access the data sent through report parameter is creating a POJO (Plain Old Java Objects) Data Source.
You should create 3 java classes and convert it to jar file and use that as input for POJO Data Source.
Make sure that column names in json file match with the properties you create in java class.
You can refer this video for more info:
"https://www.youtube.com/watch?v=3ZD8wog2pmk"
Please let us know if you get other ways to achieve the same.

JasperReports JRXML FiIl subDataSet with data

I'm trying to fill subdataset with data. I want to take data from my variable/property, fill dataset and retrieve data from dataset, using $F{field_name}. It is possible?
Yes you can fill the subdataset from main dataset. These are some steps to fill the sub dataset:-
Suppose we have field field_name in main data set and now we want to pass to the sub data set-
Create a parameter $P{p_field_name} and add the default value $F{field_name} in main dataset.
Then edit the query of sub dataset and create parameter $P{pm_field_name} and add the default value $P{p_field_name}
From my experience is not possible to fill a subdataset without using a chart or a list component. If that's your case you can see how to use a list in this video. If you need it for a chart is like this
Otherwise use a subreport and passing your $F{field_name} as datasource, it is explained here

Crystal Reports dynamic parameters values

I have crystal report with dynamic parameter (for example, linked on table COUNTRIES in some datebase).
How can i programmatically get allowed values for this parameter (list of countries)?
For static i can get default values using :
ReportDocument rd = new ReportDocument();
rd.Load(reporthPath);
rd.ParameterFields; // contains params with default values collections
Dynamic parameters has no items in DefaultValues collection. I can retrieve existing connections for report, but where i can get relation between connection and dynamic parameters?
It's not possible to do that in Crystal Reports. It's better to not use dynamic parameter field; they make your report unnecessary slow. Instead convert them to a static parameter an fill the default values from your code; that's much faster plus you know what the accepted values are.
the above answer is incorrect - as of Crystal Reports XI (at least that's where my information comes from) it is possible; see
http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crtsktutorialsrdparametersdiscrete.htm, particularly parts 2(Creating a Report with Parameters) and 5(Create a ListBox Control that Displays Default Parameters)
basically the list of possible values can be taken from the default values list,
thanks,
MD-Tech
Improving on the existing answers a little bit after running this problem to ground myself:
A ParameterField with a Static list of values has these values as items in its DefaultValues collection. The problem is that a ParameterField with a Dynamic list does not have these values pre-populated and the API does not seem to have a mechanism to query them.
A workaround involves using a Static list instead of a Dynamic one, but there may be hundreds of acceptable values which may change over time. Unless remembering to change the report(s) is appealing, a Dynamic list makes sense in this context.
In addition, using the CrystalDecisions.ReportAppServer.DataDefModel.ParameterField reveals a property BrowseField. BrowseField has properties TableAlias and Name which you can query with ADO.NET. However, BrowseField is only populated for Static parameters; it is null when using a Dynamic parameter. This is currently documented as a "needs fixed" on SAP's knowledge base, Article 2114469.
So, once you somehow get the table and column name, use ADO.NET to query the database and stick those values into the DefaultValues collection of the Dynamic parameter. Consider using a naming convention for the parameters to make this easier. Perhaps use a static parameter that isn't used in the report to house your table and column information.