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

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.

Related

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

Linking fields to subreport

In my main report I have some fields which I need to use in my subreport.
Right now I'm loading one csv file in both the main and the sub reports, but this seems to slow down the preview of my reports (I need these reports in a program). Eve if I use the preview in Crystal Reporst, it loads 3 times the same database, so I was thinking about linking the fields.
So I do Right Click on Subreport -> Change Subreport Links... and then I put the fields I want on the right side of the shown table. But when I do a preview of the whole report, in the subreport it shows only the first line and not all the values inside.
How do I manage to make the subreport show all the values of the fields?

Break Detail Line in Half?

Currently the detail prints like this:
I want to break the line in half like this:
This is what I have; Not what I want
Notes:
This is all in a sub-report if that makes any difference
I do not yet grok using formulas, variables, etc. to influence what is printed where, when, or how.
I'm working in Visual Studio 2012, I don't know the CR version.
I created Detail a and Detail b sections.
I created 2 Group Header Sections: Group Header 1a and Group Header 1b
I moved all the headers into these two groups and suppressed the Report Header Section (but not the Report Footer). Moved report fields into corresponding detail group.
Now all the detail is printed after both headers are printed. I expected this but don't know how to do what I need.
Totals are printed in the Report Footer, no issues here.
The Mystery is Solved
Created a 2nd sub report
Moved desired headings, details, and totals to the new sub report ReportHeadr, DetailSection, and ReportFooterSection respectively.
Put the new sub report directly below the original in the same (main report) section - it just happens to be a GroupHeaderSection
Changed SubReport Links ... for the new sub report. Set it identically to the original.
Notes
The sub report links setting is key to making this work. Otherwise I was getting all the data records every time this new sub report was generated, resulting in hundreds of pages.
Could not use Siva's answer. The sub report happens to be inside a Main Report's GroupHeaderSection. The report's structure does not make putting the (sub report) content into new groups and detail sections possible.
I did create multiple groups & detail sections in the sub report itself. This still gives me the undesired results illustrated in the original question posting.
if you need to view the output as you required follow below
1. Take 2 detail sections add two sub reports in main report.
2. In sub report 1 place first 3 columns and in second sub report place other two columns

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.

Multiple unrelated in JasperReports

I am using iReport with JasperReports. I want to include multiple subreports that have unrelated sql queries. I would like to be able to put these all on one report.
The problem I am facing is that when I leave the master report sql query empty, none of my subreports have any data. There isn't really anything that the master report sends to the subreports since they are unrelated. Basically how do you throw multiple unrelated reports together into one report.
In order for the Detail Band to show, you will need to fill the main report query, even if its just a dummy query, like say:
SELECT 'a' FROM DUMMY
This will make the Detail band appear, and with it all the sub reports.
Otherwise, if you don't want to use the Detail Band, you have the option to view the other bands without using a query. From Edit menu, choose Report Properties, under More... tab, set the flag When no data to All Sections, no detail