I have report that uses a subreport, but since the subreport is stored in a database table as BLOB, I cannot give its path (url) in the *.jrxml file. Is there a way to add a *.jasper file loaded from the database (BLOB or InputStream) as a subreport.
I figured it out.
Add a list component
In the list's dataset fetch the field you keep your subreport as a BLOB, lets call it
REPORT_DATA.
Set REPORT_DATA field's type to InputStream.
Add the subreport inside the list.
Set "Subreport Expression" to $F{REPORT_DATA} and its "Expression
Class" to InputStream.
Set Connection type, expression, and parameters accordingly.
Don't forget to resize the list component at least to the subreport's size, otherwise you get an error like :
net.sf.jasperreports.engine.design.JRValidationException: Band height validation for subreport ...
Related
I am working in iReport 5.6.0. I am creating a report base utilizing a table and would like to build one or more options to hide a series of columns; effectively creating a master report which will allow users to have multiple report views based on a simple parameter selection. In theory, this should work. However, I am having a problem passing a parameter from the main report it the table (where I am would use it to activate the Column Print When property.
To be clear. I have created an outer parameter and an inner parameter. I have also successfully mapped the parameters. I know that the mapping is working as I have added a column to my table and placed the parameter within the data row so that I can visually evaluate it--this too, works. However, when I set the Column Print When property as
$P{parameter1_1}.equals("y")
or even
$P{parameter1_1}.equals('y')
and then preview the report, I receive the following error:
Parameter not found: Description: parameter1_1 Object: fx $P{parameter1_1}.equals("y")
I have a parent report with a dynamic where clause, which is passed as $P!{WHERE_CLAUSE}, and the where clause in turn contains $P{} parameters
Eg: $P!{WHERE_CLAUSE}=> where docno between $P{P_FROMDOCNO} and $P{P_TODOCNO}
Values for $P{P_FROMDOCNO} and $P{P_TODOCNO} are also passed in the same execution
The parent report has a subreport, that summarizes based on certain category, whose query is based on the parent's where clause.
select vat,sum(amt) from tablename $P!{WHERECLAUSE} order by vat
So the where clause is passed to the sub-report using parameter mapping. But the subreport fails to read $P{P_FROMDOCNO} and $P{P_TODOCNO} values from the parent, resulting in empty document. All the above parameters have been mapped to the subreport parameters. The main goal is to fire the query in the database with bind parameters, even for the sub reports.
Kindly let me know if any solution for the above.
Edit: My question is not a duplicate of the mentioned question in the comments section. Because my subreport receives all the mapped parameter values, but the dynamic where clause($P!{WHERECLAUSE_SUB} which has the $P{P_FROMDOCNO} and $P{P_TODOCNO} fails to evaluate.
Thanks in advance,
Geetha
I have a problem with a report, I pass a array of values to report (from Java code) and that information is loaded inside the report (that works fine). But, I need to pass that field values to a table component, I saw and I can pass parameters to table, but I need use the main field values inside of table component and print that data there (in table component).
I suppose you pass the data from java as datasource. You have to pass the datasource for the table in a parameter and run the report with a different datasource (may be empty if you don't need any data). Then set the table datasource to be that parameter and declare the fields in the subdataset of the table.
See
How to show JRBeanCollectionDataSource data with help of Table component?
or
Two DataSource in report
for examples.
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
I have a simple SSRS report that displays data from one table. What I want to do is have a distinct list from that table displayed in a drop down list for the user to select. If I only use one dataset I can get it to display, but it displays values from the column multiple times.
Example
Bob
Bob
Bob
Cathy
Cathy
If I create a second dataset that will list distinct values I get the following error message:
An Error occurred during local report processing. The definition of the report is invalid. The Variable expression for the report 'body' refers directly to the field without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope.
I"m trying to follow the example I found here:
http://msdn.microsoft.com/en-us/library/aa337400.aspx
The second dataset is only for the parameter list. I don't understand why it's causing problems with the actual report.
It's impossible to tell exactly where without the report definition, but there is an item on the report that is referencing a field or Dataset, and was implicitly using the only Dataset present in the report, but now doesn't know which Dataset to use once more than one is added to the report.
For example, when you create a table you can set a Dataset associated with it. If this is not set and there is only one Dataset, it doesn't matter as it will take the only one available. Once you add a new Dataset, the table doesn't know which one to use and you'll get the error you're seeing.
Another way to get the error is specifying a field in an expression, e.g. in a TextBox in the report somewhere without specifying the scope; just set the scope to a particular Dataset e.g. if you have:
=Count(Fields!name.Value)
change this to:
=Count(Fields!name.Value, "DatasetToUse")
If you've only got one Dataset the first expression will run fine by using the only one available, but once you add another it won't know which to use and it will error.
in the query (SQL) you should add DISTINCT clause at the beginning, that way, you will get only one record per value. Check out http://www.w3schools.com/sql/sql_distinct.asp
Double click the Dataset which contains that field.
Go to fields on the left and delete that field.
Add new field by clicking Add -> Query Field.
Just type in the name of the new field under field name and field source.
It happens when you have added a field by selecting "Calculated Field" instead of "Query Field" from Dataset Fields list tab.
Cheers,
Ahmed Latif