将颜色应用于未找到记录的消息 [英] Applying colour to the no records found message

查看:93
本文介绍了将颜色应用于未找到记录的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jasper-reports-4.5.0和spring 3.0.5RELEASE。我正在生成PDF,HTML和CSV格式的报告。在生成报告时,如果数据库中没有匹配的记录,则显示未找到记录消息。如何使消息显示为红色?

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?

推荐答案

要将文本设置为红色,只需设置文本的前景色即可。带红色文字的无数据部分示例

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>

唯一需要注意的是,当导出到csv时,显然文本不会是红色的,因为那样只是一个纯文本文件。它应该适用于PDF和HTML。

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.

这篇关于将颜色应用于未找到记录的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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