I have been looking at the answers for the past two+ hours and I see some ideas but no sample code. I'm very new to Jasper Reports so as much detail you can provide the better.
I have an autometed scheduler running everyday at 8am to run a report. Most days the query returns zero rows so I do not want the report to be created/emailed.
I tried adding the whenNoDataType="NoPages" but that did not work. (see example below)
In reading through the questions and answers it seems I must also add something like this...
JasperPrint _prnt = JasperManager.fillReport( _rep, params, conn);
//check for pages here.--no pages helps here.
//redirect to std page
But this is pretty foreign to me. Can you provide me an example of where in the jrxml I would put the above text?
I appreciate the help
<?xml version="1.0" encoding="UTF-8"?>
pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
Your code snippets you've found are plain JAVA code and not for integration into the jrxml-design.
So if you run your report manually with API functions of JasperReports (e.g. the common steps: load design, set parameters, fill design, print/mail/export filled report result), then you could use these snippets to check whether the resulting JasperPrint Object contains pages at all and then you could prevent your mail delivery in your code.
If you use JasperServer, then the comment above by sthomas_03 would be the solution.
hth + regards