How to validate empty report in JasperReports?

后端 未结 1 861
暖寄归人
暖寄归人 2021-01-25 19:08

My situation is when I\'m not able to retrieve anything with my query, that is found inside the jasper file, a report is still generated.

I\'m using this line of code t

相关标签:
1条回答
  • 2021-01-25 19:29

    Set on jasperReport tag whenNoDataType="NoPages" or remove whenNoDataType attribute (default is "NoPages")

    Check how many pages there are in the JasperPrint, if 0 you have NoData

        JasperPrint print = JasperFillManager.fillReport(jasperReportStream, params, jdbcConnection);
        List<JRPrintPage> pages = print.getPages();
        if (pages.size()==0){
                //No pages, do not export instead do other stuff
        }
    
    0 讨论(0)
提交回复
热议问题