Detect if report is empty after rendering

Stimulsoft Reports.NET discussion
Post Reply
chrgad
Posts: 1
Joined: Mon Apr 16, 2012 3:26 am
Location: Denmark

Detect if report is empty after rendering

Post by chrgad »

Hi

How can I find out if a rendered report is empty?

I have designed some reports to be blank if the are data doesn't match the filters.

I don't want to check the data before rendering the report as the filters in the reports may change over time.

Have looked at some of the properties of the StimulReport object, but cant find what I need.
StimulReport.CompiledReport.TotalPageCount = 0 (are always 0)
StimulReport.CompiledReport.Pages.Count = 1
StimulReport.Pages.Count = 1
StimulReport.RenderedPages.Count = 1

Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Detect if report is empty after rendering

Post by Alex K. »

Hello,

As a way, you can check count of rendered pages:
StimulReport.RenderedPages.Count

Thank you.
Brainstorm
Posts: 31
Joined: Thu Feb 17, 2011 1:54 pm
Location: Cuiaba, Brazil

Detect if report is empty after rendering

Post by Brainstorm »

Normally i just check if the datasets i used are empty (count), if so, on the summary i print a "nothing to see here" message.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Detect if report is empty after rendering

Post by Ivan »

Hello,

As a workaround, you can do the following:
- define new variable in dictionary of the report, for example var1, type of int
- write the following code in the BeforePrint event of databand or headerband:

Code: Select all

            var1 = DataBand1.Count;
- use the following code for render report and get the variable value from the report:

Code: Select all

            StiReport report = new StiReport();
            report.Load("report.mrt");
            report.Render();
            int v1 = (int)report["var1"];
Now the v1 variable contain a count of rows of DataBand1. If there is no data, count will be 0.

Please check the report sample with two variables in attachment.

Thank you.
Attachments
1784.Report.zip
(2.4 KiB) Downloaded 295 times
Post Reply