I am working with jasper-reports-4.5.0 and spring 3.0.5RELEASE. I am generating the reports in PDF, HTML, and CSV formats. While generating the reports, if there are no matching records in the database I am displaying the message "No Records Found". How can I make the message appear red?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To set the text to red you just need to set the Forecolor of the text. An example No Data Section with red text would be
<noData>
<band height="20">
<staticText>
<reportElement x="0" y="0" width="555" height="20" forecolor="#FF0000"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[There was no data found.]]></text>
</staticText>
</band>
</noData>
The only caveat to this is that when exporting to csv, obviously the text will not be red since that is just a plain text file. It should work for PDF and HTML though.
标签:
jasper-reports