gpt4 book ai didi

jasper-reports - 如何隐藏指定导出器的文本字段。例如对于非 HTML

转载 作者:行者123 更新时间:2023-12-03 16:20:59 24 4
gpt4 key购买 nike

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

我不想在 HTML View 以外的任何地方显示此超链接,因为该链接在 excel、PDF、word 等中不起作用,并且显示没有意义。

我已阅读 faq与属性,但它只是让我感到困惑,因为它根本没有谈论隐藏文本字段,只是页眉和页脚的“带”。

这是我想在不是 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>

最佳答案

使用 元素键过滤器 .

来自 JR Ultimate Guide 的引述:

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、xls、csv、xml、txt、odt)添加一个属性超链接:

<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}

允许排除整个 bands (还有 group bands )。此过滤器适用于 JROrigin对象。

例如,考虑一个带有 Logo 的报表,对于 PDF 输出必须包含为 SVG,对于 HTML 输出,该报表必须包含为 PNG。 JRXML 文件包含:
    <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,请在 <jasperReport...> 之后立即添加以下属性JRXML 文件中的根元素:
<property name="net.sf.jasperreports.export.html.exclude.key.IMAGE_LOGO_SVG"/>
<property name="net.sf.jasperreports.export.pdf.exclude.key.IMAGE_LOGO_PNG"/>

关于jasper-reports - 如何隐藏指定导出器的文本字段。例如对于非 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8044930/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com