我有一个贾斯珀报告我们导出为 html 的报告。
我想如何set id报告的元素,以便新创建的 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代码转换为html td。只是想知道我们可以为此代码提供 id 或名称吗?
您应该使用该属性net.sf.jasperreports.export.html.id指示 html 导出的 id。
添加到报表元素(示例将 id 设置为 html 元素:myId
)
<property name="net.sf.jasperreports.export.html.id" value="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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)