将报表导出为HTML时,如何为报表元素提供id? [英] When exporting report to HTML, how to give id to report's element?

查看:127
本文介绍了将报表导出为HTML时,如何为报表元素提供id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a JasperReports report which we export to html.

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

I want to how to set id to report's element so that newly created html element will have that id, since later I want to make some changes to the element using 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或名字吗?

Above jrxml code is converted to html td. Just want to know can we give id or name to this code?

推荐答案

你应该使用属性 net.sf.jasperreports.export.html.id 表示用于html导出的id。

You should use the property net.sf.jasperreports.export.html.id to indicate id for html export.

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

Add to the report element (example sets id to html element as 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>

这篇关于将报表导出为HTML时,如何为报表元素提供id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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