Page 1 of 1

Printing empty reports

Posted: Mon Jul 01, 2019 6:28 am
by joro
Hello!

Some of our reports are emtpy (blank page) because the user enters criterias that yield no data.
When the user prints the report into preview then this behavior is ok because they see a blank page on the screen and realize that there is no data.
But when they send a report directly to the printer, an empty page is printed. We would like to suppress this and print no page at all.
Is there any property for the class StiReport that we could use?
We found the property 'IsRenderedReportEmpty' but it seems that it is always false.

Ho can we check if a report has loaded data from the database?
Is there any way to programmatically check this?

br
joro

Re: Printing empty reports

Posted: Mon Jul 01, 2019 8:47 am
by Lech Kulikowski
Hello,

You can check your DataSources in the Dictionary. Something like the following:

Code: Select all

report.Load("e:\\1.mrt");
((StiSqlSource)report.Dictionary.DataSources["Categories"]).SqlCommand = "select * from Categories where 1 = 0";
var isEmpty = report.Dictionary.DataSources["Categories"].Count == 0;
Thank you.