I have a JasperReports jrxml file which has a hyperlink inside a textField element.
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.
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.
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>
Best Answer
Use an Element Key Filter.
The quote from JR Ultimate Guide:
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:The expressions from your post:
allow to exclude the whole
bands
(alsogroup bands
). This filters work with JROrigin objects.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:
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: