How to access Report Name attribute from within a report?

后端 未结 2 988
粉色の甜心
粉色の甜心 2021-01-27 11:53

In a jasper report, with iReports Designer one can set the Report Name to some value (in iReports, this is on the most top node in the report inspector).

How can the val

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-27 12:25

    The answer from Alex K is correct. I just want to add additional information on how to do this in Jasper Scriplets as it might help people finding this answer:

    String nameOfReport = ((JasperReport)getParameterValue(JRFillParameter.JASPER_REPORT)).getName(); // Name of report
    String fullReportUnitPath = ((JasperReport)getParameterValue(JRFillParameter.JASPER_REPORT)).getProperty("ireport.jasperserver.reportUnit"); // path to report unit
    
    // for getting the folder name above the report file a.k.a reportunit
    int indexOfLastPathSlash = fullReportUnitPath.lastIndexOf("/");
    String nameOfReportUnit =  fullReportUnitPath.substring(indexOfLastPathSlash+1);
    

提交回复
热议问题