Jump to content
Changes to the Jaspersoft community edition download ×

Subreport problems


milto

Recommended Posts

I designed a mainReport and a subreport, but I can´t see the subreport when executing the mainReport.

 

I use the subreport Tool, and subreport's absolute path.

 

The subreport doesn't need any connection or paremeters, because it's a Static text.

 

The two Java source codes:

 

First:

 

JasperReport jasperReport;

JasperPrint jasperPrint;

Map parameters = new HashMap();

ReportSource reportSource=new ReportSource(con);

 

jasperReport = JasperCompileManager.compileReport(

"c:/java/workspace/JasperOskar/conf/MainReport.jrxml");

 

jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,reportSource);

 

JasperExportManager.exportReportToPdfFile(

jasperPrint,"c:/java/workspace/JasperOskar/conf/mainReport.pdf");

 

 

Second:

 

JasperReport jasperReport;

JasperPrint jasperPrint;

Map parameters = new HashMap();

ReportSource reportSource=new ReportSource(con);

 

JasperReport masterReport = null;

 

masterReport = (JasperReport) JRLoader.loadObject("c:/java/workspace/JasperOskar/conf/MainReport.jrxml");

 

JasperReport subReport1 = null;

 

subReport1 = (JasperReport) JRLoader.loadObject("c:/java/workspace/JasperOskar/subReport.jrxml");

 

Map masterParams = new HashMap();

masterParams.put("SUBREPORT",subReport1);

 

JasperPrint masterPrint = null;

 

masterPrint = JasperFillManager.fillReport(masterReport, masterParams,reportSource );

 

JasperExportManager.exportReportToPdfFile(

masterPrint, "c:/java/workspace/JasperOskar/conf/MainReport.pdf");

 

JasperViewer.viewReport(masterPrint, false);

 

 

Please help me as I need a solution.

 

Thanks.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

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