Repeat main report rows per each subreport row - jasper-reports

I have a JasperReports's report already implemented using below data structure which prints a main record along with its subreport records. The main and the subreport are placed in the same detail band and the subreport uses the JRBeanCollectionDataSource($F{employees}) as its data source expression $F{employees} being the collection field on the main report data type Company.
Company
Name
Location
Employees
Employee
ID
Fullname
etc.
The question is if there is an option in report to repeat the main report columns (Name, Location..) for each subreport record I have for a certain Company?
Basically, I need repeated records in the main report.
I know this is ugly and may look pointless but that is the Business Requirement! Most importantly, I don't want to touch the existing data structure as it's more complex in real case than my example.
Any hint (could be even a hack in JasperReports) is highly appreciated.
Note: I'm using iReport 3.7.3 editor.

Related

How to generate a page in report for each data row using SSRS

I am working on developing an SSRS report.I have a table in which student name and 6 subjects marks is stored in each row. My problem statement goes like this ---> lets say if 10 rows of data is present in table then I want to create report card/ marksheet for each student in new page but inside a same report. (I.e. 10 pages in one report). Then convert the report containing 10 pages to PDF format and save it in some folder.
Can anyone show some possibilities to achieve my problem statement.
Thanks in advance....
Usually you'll want to use a List object to separate your report by student. You would group the list by student in your report. Then set a Page Break in the List with the location to Between each group so that it separates each student into a separate page.
Then you can put charts, tables and other object inside the list and it will repeat with the list group (in your case, each student).
MSDN: Lists
In this report I made below, the List is highlighted in Red and groups by each site. It just has a table inside. When it's run each site gets it's own page with a list of their people.
Keep in mind that a List is actually just a Tablix with only one data cell - with the column and row headers removed.

I Want to Print 1 report in two copies(2 Prints ) with same data in crystal report having Subreport?

Normally if we have report without any sub report in it, it is easy to print twice the report by adding same report in page footer as sub report . But if report contains already subreport than it is not possible to again add subreport in it. So how can we Print such report twice in crystal report.
It must exist a better solution, but here it goes two workarounds:
Alternative 1:
Turn your main report into a subreport (with its child subreport) and duplicate it in a brand new main report.
Advice: subreports use to perform poorly, but if your data is not large, it is ok.
Alternative 2:
If you can easily manipulate the data source (for example, if your generating a dataset through code), use the details section for your report, insert an extra table in your data source where the number of lines is the number of "copies" that you want to print. Let your main table join with this "fake" table without links. The result will be a cartesian product, so you will get the number of copies you want.
Extra note: Crystal let you use another rpt file as a subreport. Maybe you can use this feature to solve your problem. Personally, I don't like this feature, because it does not behave like I would expect by intuition.

my table jasper report repeat the data many time [duplicate]

I am new to JasperReports, basically I want to put a subreport in a mainreport
The problem is that I put the sub report in the Detail band, so when I query a database that has multiple data the subreport will always repeat itself multiple times when I output the report to a pdf. I want a report that does not repeat itself regardless of how many data I have in the database that i connect with
I have searched the Internet and the solutions is to add
new Boolean($V{REPORT_COUNT}.intValue()==1)
in the print when expression attribute of the subreport, that does solve a part of my problem due to the fact that now my subreport only prints once but it still leaves some blank pages after my subreport is displayed
So I assume it is still repeating itself but just doesn't print the data because of the expression that I added , people say that the nature of the detail band is supposed to work that way and that I shouldn't put the subreport in the detail band, but if I put it in some other band I get this error:
Error filling print... Subreport overflowed on a band that does not support overflow.
The error above will happen if I have a lot of data to the extent that it may take up more than a page.
How do remove those blank pages? If I am ask to not put it in a detail band then what should I do? or what solution are there?
The Detail band will be generated as many times as the number of records you have in your main dataSet(populated by the top-level query).
If you want to keep the subreport in the Detail band, which is normal by the way, you can do one of these things:
either have a dummy query that returns only one record, so that the Detail band generates only once. Then, pass the report connection to your subreport. You may have done that already. This way you can run your query independently of the main report.
or leave the report as-is and add your printWhen expression ($V{REPORT_COUNT}.intValue()==1) directly on the Detail band, not on the subreport. Please note that this is just an ugly hack that may affect the report performance. Your main query still returns a lot of data that you don't use so you should consider the other options.
If you can move the subreport out of the Detail band, place it in a band that allows overflow like Title or Summary band. Then:
have your main dataSet's query empty so that no Detail band gets generated
set whenNoDataType="AllSectionsNoDetail" at the report level(in the <jasperReport> tag) so that all the other sections except the Detail get generated
exactly as in the first option above, pass the report connection to your subreport and work from there

Multiple Crystal Report to be printed on same report

I have a crystal report that takes only about 1/3rd of the report space.
I have field read from the database which is an integer value.
I wish to print this report number of times as read from the database on the same page.
Any idea on how this can be achieved?
I can only use crystal report for achieving this.
Thanks in advance.
You can create another report and add your current report as a subreport multiple times
Lan is correct, build another report and add your current report as a subreport.
Here's the trick:
On your main report, have it make a list of all of the items that
you'd like to run the sub-report on.
On your sub-report, add a parameter called "itemNumber" or something like that. Then change your Subreport Links so the new "itemNumber" parameter is linked to the item on your top level report.
Now hide the field on the main report but leave the
subreport visible.!
This should make your report run for all items at one time.
In this case you can create a table with the maximum number of prints you will ever use. For example if you think you might need to print the report 100 times your table should contain records from 1 to 100. So lets assume this is the case- create a table , name it Copies and add a field CopyNo. Create a 100 records and set CopyNo from 1 to 100. Create the a main report based on Copies table - the record selection formula will be something like :
Copies.CopyNo<=#NumberOfCopies
#NumberOfCopies is a parameter , which you can set in order to control the printed copies. Create your actual report as a subreport and place it in the details section of the main report. When you run the report it will ask you for the number of copies and when you insert it, will print the same subreport as many times as the number you provide.

Displaying a Tree Structure in Crystal Reports

Does anyone know of a way to represent a tree structure in Crystal Reports?
My big issue is that I don't know the depth of the tree. It is represented in a database table with a simple "childId -> parentId" relationship.
A perfect example would be to open Windows Explorer, and look at the directory tree on the left side. If anyone knows a way to represent that tree, then it'll work for what I need to do too.
My initial attempts have been:
1) to programatically (in C#) add Groups to the report. Unfortunately, you can't create a new instance of the Group class and add it to the Groups collection.
2) recursively nest the same report into itself for each level. In other words:
mainReport
subReport
subReport
subReport
subReport
subReport
subReport
etc...
Unfortunately, SubReports can't contain SubReports.
I really don't want to just add X number of groups into a report and hide the ones I don't need, because I'd have to add a fixed number of nested groups, but technically the data design can support an infinite depth, even though in practice we see up to about 5 levels of depth.
So, any other ideas?
Crystal XI added hierarchical grouping. You'll find this under the Reports menu. I put together a quick org chart report with n-level depth using this. The database table is like:
id
name
managerId
In the Crystal Report, you select these columns, group by id. Then under "Hierarchical Grouping options" menu under Reports, check off "Group Data Hierarchically", parent Id managerId, and indent appropriately.
The output is like the tree you described in Explorer.