如何从报告中访问“报告名称"属性? [英] How to access Report Name attribute from within a report?

查看:61
本文介绍了如何从报告中访问“报告名称"属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个碧玉报表中,可以使用iReports Designer将报表名称"设置为某个值(在iReports中,该名称位于报表检查器的最高节点).

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 value of this parameter been accessed later within e.g. a variable or a textfield of the same report?

推荐答案

借助 JASPER_REPORT 参数,我们可以获得

With help of JASPER_REPORT parameter we can get instance of JasperReport class. This is the current template object.

借助 JasperReport. getName()方法,我们可以获取报告名称.

With help of JasperReport.getName() method we can get the report name.

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Show the report name example" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <title>
        <band height="50" splitType="Stretch">
            <textField>
                <reportElement x="110" y="0" width="290" height="25"/>
                <textFieldExpression><![CDATA[$P{JASPER_REPORT}.getName()]]></textFieldExpression>
            </textField>
        </band>
    </title>
</jasperReport>

在此示例中,报告的名称为:name="Show the report name example"

In this example the name of report is: name="Show the report name example"

这篇关于如何从报告中访问“报告名称"属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆