Jump to content
Changes to the Jaspersoft community edition download ×

Subreport and Main Report Problem -- Urgent


2006 IR Open Dicussion

Recommended Posts

By: ryan - ryankee

Subreport and Main Report Problem -- Urgent

2006-06-06 05:04

Hi, I have the following code::

 

*************************************************

public class JRpt {

 

public static byte[] runReport(Age,

Gender) throws Exception

{

 

Map parameters = new HashMap();

parameters.put("p_Age",Age);

parameters.put("p_Gender",Gender);

 

Connection jdbcConnection = connectDB(databaseName, userName, password);

JasperPrint jasperPrint = JasperFillManager.fillReport(reportFile, parameters, jdbcConnection);

byte[] output = JasperExportManager.exportReportToPdf(jasperPrint);

return output;

}

}

*************************************************

Basically, this main report has a subreport. But when i run the class program, it keeps saying "Could not load object from location : TestSubRpt.jasper". I saw some forum on this that you need to pass subreport as a parameter into the main report with the java codes. But I'm not sure how to do it. Can someone pls help.

 

Thanks

Ryan

 

 

 

 

By: Martyn - martyn-hi-ss-nl

RE: Subreport and Main Report Problem -- Urge

2006-06-07 02:23

You need to load the subreport in a java class. I load a report using getClass().getClassLoader().getResourceAsStream() and then I convert the inputstream into a jasperreport using JRLoader.loadObject()

 

Then add the report to the parameters map that you pass to the fillReport function.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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