Jump to content
We've recently updated our Privacy Statement, available here ×

How to do Batch Reporting using Jasper


ktrinad

Recommended Posts

By: V.A.V.K. Kishore - javakishore

How to do Batch Reporting using Jasper

2004-07-29 10:50

Hi I need help in solving this problem.

 

In my project, we search order and in search results page, we choose an order and generate order report for the selected order using JasperReports. We developed JasperReports XML to suit only for single order i.e individual order report. We have two kinds of orders, purchase order and sales order and for each order we developed separate JasperReport XML s (PO.xml, SO.xml). It is working fine.

 

Now there is a requirement change and the new requirement is, we need to generate report for more than one order at a time i.e. in a single PDF we should have all order details. User will select a customer, choose start date and end date and click on a button  Generate Batch Report . Then we need to get all the orders created for the selected cusomter and generate a Batch Order Report for that customer order by created date descending.

 

Problem Definition:

Problem is, we have two separate XML s for Purchse Order and Sales Order. When we get all the orders for the customer and iterate through each order, check what kind of order it is. If it is PO, then we need to use PO.xml, if it is SO then we need to use SO.xml

 

We are in a position where we cannont write a single XML which has logic for both PO and SO.

 

Requirement:

How can I achieve this Batch Order Report with two separate XML s and with final output as Batch Order Report for a customer in a single PDF

 

My questions:

Can I use subreports here?

If I have main SQL query in a main report then how should I map columns in the record set to fields in the subreport?

Do I need to have SQL query in sub report also?

 

Please help

 

Thanks

Kishore Veleti

 

 

By: Chuck Deal - cdeal

RE: How to do Batch Reporting using Jasper

2004-07-29 11:16

I have two ideas:

 

1. Create another report. This will act as a wrapper. The datasource (SQL) for this report would include enough info to load one of the specialized reports (SO, PO). From you example, this would be at least the order number and type of order. This report would then define two subreports in the detail group. Each subreport would use a printwhenexpression tag that is based on the order type. Therefore, only one subreport would be active for each order returned by the datasource. In this way, you would produce one report that had the SO and PO reports mixed (in date order).

 

2. You could have a bit of code outside the reports that would generate the JRPrint objects for each report and stick them into a List. You would not export them to PDF yet. Then using the batch export feature of JasperReports (0.6.0 it is built-in, pre-0.6.0 requires a patch) you could then export all of the filled reports to one PDF file.

 

 

 

 

By: Daren O - rckrll106

RE: How to do Batch Reporting using Jasper

2004-07-29 11:42

I agree that generating the JRPRint objects and storing them in a list would be probably the least amout of work for you.

 

I've done the same thing for very complicated reports where subreporting gets tricky or impossible.

 

I'm not sure how the batch export feature works (but sounds interesting). However, you could create a JRPrint object to store all your pages in your list and export in any format using the existing exporters (and its possible that is how the batch exporter works).

 

JRPrintPage jrpp = null;

for (int i = 0; i < arrayListSize; i++) {

jrpp = (JRPrintPage) alist.get(i);

}

origReport.addPage(jrpp);

} //end of for loop

 

 

 

By: Daren O - rckrll106

RE: How to do Batch Reporting using Jasper

2004-07-29 11:46

Sorry, the last post had one too many brackets...

 

JasperPrint origReport = new JasperPrint();

 

JRPrintPage jrpp = null;

for (int i = 0; i < arrayListSize; i++) {

jrpp = (JRPrintPage) alist.get(i);

origReport.addPage(jrpp);

} //end of for loop

 

And another thing. You could change the order of reports (if you wanted) using this method and you wouldn't have to rely on the order they were created.

 

 

 

By: V.A.V.K. Kishore - javakishore

RE: How to do Batch Reporting using Jasper

2004-07-30 00:14

How to create JRPrintPage objects?

 

I have Jasper XML in compiled format and I have data from the DB, with this info how can I create JRPrintPage objects ?

 

 

By: Mykel Alvis - evilarchitect

RE: How to do Batch Reporting using Jasper

2004-07-30 06:42

RTM

 

http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperFillManager.html

 

produces JasperPrint

 

getPages() on a JasperPrint produces a List of JRPrintPage

 

 

By: V.A.V.K. Kishore - javakishore

RE: How to do Batch Reporting using Jasper

2004-07-30 07:32

Hi Mykel

 

Thanks for your immediate responses. I am very happy for the suggestions you provided, I am able to achieve batch report as suggested by you.

I found ni Jasper 0.6 version there are few changes in commons-xxx.jar files also.

 

Now I have few problems:

 

1. I am using Jasper 0.3.0 version, I cannot change to Jasper 0.6 version, can I know where I can get the batch export functionality patch for Jasper 0.3.0 version. I search in patches link, I found only Jasper 0.6 build but not patch for this.

 

Please help

 

Thanks,

Kishore Veleti

 

 

By: Mykel Alvis - evilarchitect

RE: How to do Batch Reporting using Jasper

2004-07-30 07:36

Sorry, dude. You're off the version boat and it's sailing away from you.

If you want to add batch processing to an older version of JR, then you're going to have to take the batch code from 0.6.0 and try to reverse-implement it in an earlier version.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...