Applying colour to the no records found message

2019-07-30 00:06发布

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条回答
姐就是有狂的资本
2楼-- · 2019-07-30 00:44

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.

查看更多
登录 后发表回答