Page 1 of 1

Detect if report is empty after rendering

Posted: Mon Apr 16, 2012 3:57 am
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

Detect if report is empty after rendering

Posted: Mon Apr 16, 2012 9:41 am
by Alex K.
Hello,

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

Thank you.

Detect if report is empty after rendering

Posted: Tue Apr 17, 2012 5:30 pm
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.

Detect if report is empty after rendering

Posted: Wed Apr 18, 2012 5:10 pm
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.