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

How to get subreport from master report


2005 IR Help

Recommended Posts

By: Barra - booleong

How to get subreport from master report

2004-09-07 04:38

I set subreport in master report using a string of path

- <subreportExpression class="java.lang.String">

- <![CDATA[ "report/ResourcesSubreport.jasper" ]}>

</subreportExpression>

 

As i need to modify the fonts of the sub report, i need to extract the object JasperReport of the sub report from the master. Can this be done?

 

At the big picture, i'm trying to dynamically change fonts according to jvm locale. Normally, this is done before filling report. However when subreport is nested under a master, i'm unable to get the object JasperReport to modify the fonts.

 

 

 

 

By: C-Box - c-box

RE: How to get subreport from master report

2004-09-07 05:20

Well you have to parse the MasterReport for all SubReports that are within that MasterReport.

 

I've done it with a method that collects all bands and then for each band all elements ... then I go through these elements and look for SubReports...

 

[a loop to pase all bands bla bla bla....]

....

JRElement myElem = null;

JRBaseSubreport mySubReport = null;

String elemExpression = null;

JasperReport repObject = null;

....

else if (myElem instanceof JRBaseSubreport) {

mySubReport = (JRBaseSubreport) myElem;

elemExpression = mySubReport.getExpression().getText();

repObject = getMyCompiledSubReportFromLocation(elemExpression);

if (repObject != null) {

//write your own method that gets the SubReport from your file with e.g. JRLoader or whatever

// do what you want here with your SubReport as JasperReport - Object e.g. try to change your font's

}

}

 

[bla bla bla]

 

So you get to your SubReports that are located anywhere on your MasterReport.... perhaps not the best way, but I don't know any better and it was enough for my purpose.

 

I'm sure you have to put your subReports as parameter to your masterreport when filling to push the changed subreports and not let the masterreport load the subreports from file again.

 

hth

C-Box

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...