I have a report which has a dataset. I want to print No Data Band whenever the query in the dataset returns 0 records (empty dataset).
I have set the "When No Data" to "No Data Section". But it doesn't seem to be working.
Any Suggestions?
In order to print No data band whenever the query in the dataset returns 0 records(empty dataset) follow these steps:-
After adding No data band whenever query will return 0 record "No Data" band will display the static text.
For those like myself, who do not use JasperSoft or older iReport and directly work with XML, do the following:
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
whenNoDataType="NoDataSection"
name="freport" pageWidth="595" pageHeight="842"
columnWidth="555" leftMargin="20" rightMargin="20"
topMargin="20" bottomMargin="20">
Add whenNoDataType="NoDataSection"
to the <jasperReport>
element.
<noData>
<band height="15">
<staticText>
<reportElement x="0" y="0" width="200" height="15"/>
<box>
<bottomPen lineWidth="1.0" lineColor="#CCCCCC"/>
</box>
<textElement />
<text><![CDATA[The report has no data]]> </text>
</staticText>
</band>
</noData>
Add <noData>
element below the detail band.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With