0

I've 1 mainreport.xrml and this report has a subreport.xrml.

So when I compile my report without giving the report any reference to my subreport it generates my report fine, but when I give the reference inside the report.xrml to my subreport, it asks me for my subreport.jasper

Here is my java code to do the compiling:

JasperReport report = null;
JasperReport report2 = null;
JasperPrint jasperPrint = null;
StringBuilder pathReport = new StringBuilder();
try {
    name = config.getProperty(Constants.PATH_JRXML) + name + SUFFIX;
    String name2 = "";
    if (tipoReporte.equals("mensual")) {

    } else {
        int a = 0;
        name2 = "C:\\mail\\reporteIncidenciasDiarias.jrxml";
        report2 = JasperCompileManager.compileReport(name2);
    }

    report = JasperCompileManager.compileReport(name);

    jasperPrint = JasperFillManager.fillReport(report, mapParams,
            new JRBeanCollectionDataSource(params));

    pathReport.append(config.getKeyValue(Constants.PATH_REPORT));

    String nombreReporte = config.getKeyValue(Constants.NAME_REPORT);
    if (tipoReporte.equals("mensual")) {
        nombreReporte += "Mensual";
    } else {
        nombreReporte += "Diario";
    }

    pathReport.append(nombreReporte);
    pathReport.append(DateUtils.formatear(new Date(), Constants.PATTERN_DATE_2));
    pathReport.append(Constants.FILE_EXT);

    JasperExportManager.exportReportToPdfFile(jasperPrint, pathReport.toString());
    logger.info("Reporte generado " + pathReport);

} catch (JRException e) {
    logger.error(e);
    throw new Exception(e);
} catch (Exception ex) {
    logger.error(ex);
    throw new Exception(ex);
}
return pathReport.toString();

What should I do so it doesn't ask me for my subreport.jasper or how can I get my subreport.jasper?

Alex K
  • 22,315
  • 19
  • 108
  • 236
linker85
  • 1,601
  • 5
  • 26
  • 44
  • possible duplicate of [Generate Jasper report with subreport from java](http://stackoverflow.com/questions/9785451/generate-jasper-report-with-subreport-from-java) – Alex K May 24 '13 at 07:00

1 Answers1

0

Use a file resolver and pass it as a parameter to your report or compile the subreport file by yourself and pass the compiled report.

Have a look at the jasperreports samples:

http://jasperreports.sourceforge.net/sample.reference/subreport/index.html#subreports

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555