How to use Details band to display multiple data sets - jasper-reports

I have a JasperReports's report with 10 rows fetched from the main query..
When i run the report it will show 10 rows without a problem.
Now when i add another band with fields of a data set in a list item. It is repeated for every record in the main report!. :(
How can i avoid this situation and change the second details band to print when the main report data has finished printing on the first band?
I would want to achieve this without going for sub-reports as it's difficult to maintain many files for a single report.

I have learned a lot on jasper reports over time and I'm posting the answer for my very own question to help someone in future.
What you need to do is for complex, Multi-query reports you create the main report with a simple query like this.
SELECT SYSDATE FROM DUAL
What this means is that when it's run main report details band will have a single iteration. That means if we have used the SYSDATE field in the details band it will print once.
OK, now if you follow the following steps you should be able to achieve the above task successfully.
Add two details band to the report (you must be having one details band by default, to add another right click --> add another detail band)
Add two data-sets to the main report (right click on the report and select Add Dataset)
Now all you need to do is use those two data sets in the previously created details bands by using either a list item or table item (personally I would recommend table as you can do lot of advanced stuff in that)
Hope this will help someone in the future. let me know if you need more help!. Cheers!!

Related

Jasper report to call two independent queries and display results in one report

Similarly i have an requirement that, in one main excel report should have tittle only, and then need to call two independent queries and display the results below the tittle. Just need to send counts of records from both queries to main report.
I don't want to repeat the results just display once.
Thats basically what subreports are for. You can create one JRXML-report which contains two child (sub)reports. Each subreport can have its own Query.
PS : The detail Band is rendered once per Resultset. So maybe it is enought to use this.

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.

Crystal reports 2008 report writing

Hi
I'm trying to write my first report!!!
and have number of question I cant seem to find the answer to can anyone help me please!
Q1.
i drag a DB field on the the report which is a string format and need to divide the value by 1024 and display the result. I know i need to use tonumber({fieldname}] but don't know where or how to add this and then do the division. how do I do it?
Q2.
on the report I have a group in its header I have the items that display across the report. in the detail I have the fields of a table that relate to above line. all good so far! How do add another Group or section that would allow another collection of data relating to the same first line!
as I see it I need to add another group with another detail section but I can't do this!
Hope this make some sort of sense!
thanks
Answer 1:
That operation should be done in a formula -- the formula editor will provide views to functionality you can access in that context.
Answer 2:
The Group Editor is what you need to use. You can access it from one of the menus at the top, or by right clicking the row header for the appropriate section IIRC.

crystal report problem

what is the equivalant command like in vb for EOF(), MoveNext, Moveprevious commands in crystal reports
There are no equivalent answers in Crystal Reports, at least not in the versions I have used. Crystal Reports more or less simply dumps the data out into the report.
That said, if you are in a detail row, and you want to find out what the next value of a field will be, you can use:
next({YourColumn})
You can also find out the previous column value by using this:
previous({YourColumn})
Keep in mind that Next() won't work on the last record, and Previous() won't work on the first record.
I'll have to double-check, but I believe there is an OnLastRecord function that returns TRUE if you are on the last record.
First, welcome to SO!
Second, you sound new to Crystal Report's purpose is to display data, not perform the kind of calculations you're talking about. CR usually goes record-by-record through the data, displaying (or suppressing) each record, and adding group headers & footers.
To answer your question, LittleBobbyTables does give a few good pointers. To see the entire list of functions available to you, there is a list in the Formula Editor (see pic below). Press F1 for detailed descriptions of each command.
You can also:
Create a "Running Total Formula" that will evaluate each record and give a calculation in the group footer.
Do the calculations outside of Crystal Reports and only feed the end result in (perhaps with an unlinked join to your primary table).
The most complex option is to make a subreport that does the calculation and feeds the result back to the main report
Can you give us some more details about what you're trying to do?