将报表导出为HTML时,如何为报表';s元素?

将报表导出为HTML时,如何为报表';s元素?,html,jasper-reports,Html,Jasper Reports,我有一个JasperReports报告,我们将其导出为html 我想知道如何将id设置为report的元素,以便新创建的html元素具有该id,因为稍后我想使用JavaScript对元素进行一些更改 当前jrxml代码 <pageHeader> <band height="40" splitType="Stretch"> <staticText> <reportElement key

我有一个JasperReports报告,我们将其导出为html

我想知道如何将id设置为report的元素,以便新创建的html元素具有该id,因为稍后我想使用JavaScript对元素进行一些更改

当前jrxml代码

<pageHeader>
        <band height="40" splitType="Stretch">
            <staticText>
                <reportElement key="staticText-1" mode="Opaque" x="0" y="20" width="730" height="20" forecolor="#FFFFFF" backcolor="#5F8A1B"/>
                <box>
                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" lineSpacing="Single">
                    <font fontName="Verdana" size="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                </textElement>
                <text><![CDATA[Test ]]></text>
            </staticText>
        </band>
    </pageHeader>


上面的jrxml代码被转换为HTMLTD。只是想知道我们可以给这个代码指定id或名称吗?

您应该使用该属性来指示html导出的id

添加到report元素(示例将html元素的id设置为
myId


在你的例子中

<pageHeader>
    <band height="40" splitType="Stretch">
        <staticText>
           <reportElement key="staticText-1" mode="Opaque" x="0" y="20" width="730" height="20" forecolor="#FFFFFF" backcolor="#5F8A1B">
               <property name="net.sf.jasperreports.export.html.id" value="myId"/>
           </reportElement>
           <box>
                <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" lineSpacing="Single">
                <font fontName="Verdana" size="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
            </textElement>
            <text><![CDATA[Test ]]></text>
        </staticText>
    </band>
</pageHeader>

<pageHeader>
    <band height="40" splitType="Stretch">
        <staticText>
           <reportElement key="staticText-1" mode="Opaque" x="0" y="20" width="730" height="20" forecolor="#FFFFFF" backcolor="#5F8A1B">
               <property name="net.sf.jasperreports.export.html.id" value="myId"/>
           </reportElement>
           <box>
                <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" lineSpacing="Single">
                <font fontName="Verdana" size="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
            </textElement>
            <text><![CDATA[Test ]]></text>
        </staticText>
    </band>
</pageHeader>