How to hide textField in report generated in speci

2019-07-22 11:21发布

I am using the JasperReports 4.7, Trying to hide a text field while exporting to pdf,xsl. I've tried the using of net.sf.jasperreports.export.{format}.exclude.origin.{suffix}.{arbitrary_name} property.

It didn't work. Any suggestions?

1条回答
相关推荐>>
2楼-- · 2019-07-22 12:15

You should use another property: net.sf.jasperreports.export.{format}.exclude.key.{keyvalue}, where the keyvalue is element's key to exclude.

Example.

The jrxml file:

<?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="exclude_textfield_sample" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5207ad85-202f-4b93-ba07-39185c10d443">
    <property name="net.sf.jasperreports.export.pdf.exclude.key.tfToHideInPDF"/>
    <title>
        <band height="79" splitType="Stretch">
            <textField>
                <reportElement uuid="11c36fdc-c1ff-4901-a2cc-f939439c83f2" x="87" y="30" width="150" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA["Text field not to exclude"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="8524232f-a769-478d-9a6d-643548e6555f" key="tfToHideInPDF" x="269" y="30" width="187" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA["Text field to exclude"]]></textFieldExpression>
            </textField>
        </band>
    </title>
</jasperReport>

In this report I've placed two textFields: first with key="tfToHideInPDF" to exclude in pdf file and the second for showing in all report's formats.

The report's design (in iReport):

enter image description here

The rtf document generated with RTF Preview in iReport is:

enter image description here

And the dpf document generated with PDF Preview in iReport is:

enter image description here


If you want to hide textField additionally in rtf format, for example, you should just add another property: <property name="net.sf.jasperreports.export.rtf.exclude.key.tfToHideInPDF"/>. And so on.

查看更多
登录 后发表回答