如何隐藏指定导出器的textField。例如,不是HTML [英] How to hide textField for specified exporter. For example for not HTML

查看:84
本文介绍了如何隐藏指定导出器的textField。例如,不是HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 JasperReports jrxml 文件,它在textField元素中有一个超链接。

I have a JasperReports jrxml file which has a hyperlink inside a textField element.

我不想在任何东西中显示这个超链接除了HTML视图之外,因为链接在excel,PDF,word等中不起作用,并且显示没有意义。

I do not want to show this hyperlink in anything other than the HTML view because the link does not work in excel, PDF, word, etc. and does not make sense to show.

我已阅读 faq 与属性但它只是让我感到困惑,因为它没有谈论隐藏 textField ,只是页眉和页脚的乐队。

I have read the faq with the properties but it just confused me because it does not talk about hiding a textField at all, just "bands" for headers and footers.

这是我想要隐藏的文本字段,而不是HTML:

Here is the text field I want to hide when not HTML:

<textField hyperlinkType="ReportExecution">
    <reportElement style="Report_Param_Value_Link" mode="Opaque" x="400" y="0" width="161" height="20"/>
    <textElement/>
    <textFieldExpression class="java.lang.String"><![CDATA[Boolean.TRUE.equals($P{LAST_WEEK}) ? "View WTD" : "View last week"]]></textFieldExpression>
    <hyperlinkParameter name="noMenu">
        <hyperlinkParameterExpression><![CDATA["true"]]></hyperlinkParameterExpression>
    </hyperlinkParameter>
    <hyperlinkParameter name="reportUnit">
    <hyperlinkParameterExpression><![CDATA["repo:/Reports/Operations/Business_Support/Subreports/Business_Support_Performance_Dashboard"]]></hyperlinkParameterExpression>
    </hyperlinkParameter>
    <hyperlinkParameter name="LAST_WEEK">
        <hyperlinkParameterExpression><![CDATA[Boolean.valueOf(!Boolean.TRUE.equals($P{LAST_WEEK})).toString()]]></hyperlinkParameterExpression>
    </hyperlinkParameter>
</textField>


推荐答案

使用 元素密钥过滤器 即可。

Use an Element Key Filter.

来自 JR Ultimate Guide 的报价:


此内置过滤器实现从与给定元素键匹配的导出元素中排除。

元素键在报告设计时设置并传播到生成的报告中。

每个填充报表中的元素与生成它的报表模板中的元素具有相同的键。

要触发元素键过滤器,报表设计者需要定义一个或多个以<1开头的报表属性。强> < exporter_property_prefix> .exclude.key 即可。每个这样的属性匹配单个元素键,该元素键将被过滤器排除。元素键由属性值给出,或者如果没有为属性设置值,则由属性后缀给出。

以下示例说明如何指定要从特定导出中排除的元素键输出:

This built-in filter implementations excludes from export elements that match a given element key.
Element keys are set at report design time and are propagated into generated reports.
Each element in a filled report has the same key as the element from the report template that generated it.
To trigger an element key filter, the report designer needs to define one or more report properties that start with <exporter_property_prefix>.exclude.key. Each such property matches a single element key which is to be excluded by the filter. The element key is given by the property value, or if no value is set for the property, by the property suffix.
The following example shows how to specify element keys which are to be excluded from specific export outputs:



<jasperReport ...>
    <!-- exclude elements with keys Image1 and Text4 from HTML export-->
    <property name="net.sf.jasperreports.export.html.exclude.key.Image1"/>
    <property name="net.sf.jasperreports.export.html.exclude.key.Text4"/>
    <!-- exclude elements with keys Image5 from PDF export -->
    <property name="net.sf.jasperreports.export.pdf.exclude.key.the.image" value="Image5"/>
    ...
</jasperReport>

在您的情况下,您应该为带有超链接的文本字段添加密钥(例如, textFieldWithHL )然后为要从打印此超链接中排除的每种格式(pdf,docx,xl​​s,csv,xml,txt,odt)添加一个属性:

In your case you should add key for text field with hyperlink (for example, textFieldWithHL) and then add one property for each format (pdf, docx, xls, csv, xml, txt, odt) you want to exclude from printing this hyperlink:

<property name="net.sf.jasperreports.export.pdf.exclude.key.textFieldWithHL"/>
<property name="net.sf.jasperreports.export.docx.exclude.key.textFieldWithHL"/>
<property name="net.sf.jasperreports.export.xls.exclude.key.textFieldWithHL"/>
<property name="net.sf.jasperreports.export.csv.exclude.key.textFieldWithHL"/>
<property name="net.sf.jasperreports.export.xml.exclude.key.textFieldWithHL"/>

您帖子中的表达式:

net.sf.jasperreports.export.{format}.exclude.origin.{suffix}.{arbitrary_name}
net.sf.jasperreports.export.{format}.exclude.origin.keep.first.{suffix}.{arbitrary_name}

允许排除整个乐队(同样乐队乐队)。此过滤器适用于 JROrigin 对象。

allow to exclude the whole bands (also group bands). This filters work with JROrigin objects.

例如,考虑一个带有徽标的报告,该徽标必须包含为PDF输出的SVG或HTML输出的PNG。 JRXML文件包含:

For example, consider a report with a logo that must be included as SVG for PDF output or PNG for HTML output. The JRXML file contains:

    <image scaleImage="RetainShape" onErrorType="Blank">
        <reportElement key="IMAGE_LOGO_PNG" x="1" y="0" width="100" height="60" uuid="a896cade-f6fc-4d8f-b762-29b950309257"/>
        <imageExpression><![CDATA[Transcoder.asPNG($V{V_LOGO_FILE} + ".svg")]]></imageExpression>
    </image>
    <image scaleImage="RetainShape" onErrorType="Blank">
        <reportElement key="IMAGE_LOGO_SVG" x="1" y="0" width="100" height="60" uuid="a896cade-f6fc-4d8f-b762-29b950309257"/>
        <imageExpression><![CDATA[Transcoder.asSVG($V{V_LOGO_FILE} + ".svg")]]></imageExpression>
    </image>

要从HTML中排除SVG并从PDF中排除PNG,请在<$后立即添加以下属性c $ c>< jasperReport ...> JRXML文件中的根元素:

To exclude the SVG from HTML and the PNG from PDF, add the following properties immediately after the <jasperReport...> root element in the JRXML file:

<property name="net.sf.jasperreports.export.html.exclude.key.IMAGE_LOGO_SVG"/>
<property name="net.sf.jasperreports.export.pdf.exclude.key.IMAGE_LOGO_PNG"/>

这篇关于如何隐藏指定导出器的textField。例如,不是HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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