Solved

Suppress Exporting Crystal Report as PDF IF No Data

Posted on 2007-12-06
4
1,472 Views
Last Modified: 2008-02-01
Hello,

I batch export several Crystal Reports as PDF using a VB.NET 2003 Windows application.  However, since I am exporting to PDF and not printing, I cannot suppress if there are no records anymore.  The property the report has to suppress printing if no data doesn't apply to exporting as PDF.  Therefore,  I end up with several PDFs that are blank because they did not have any records.

I'm using the ReportDocument (CR)  class and the CR.ExportOptions process to export.  Here's a sample of what I do after the report is ready to be exported.

Dim CR as New  ReportDocument
..
..' provide path to open the report and enter parameters here too.

With CrExportOptions
        ' Set the destination to a disk file
      .ExportDestinationType = ExportDestinationType.DiskFile
      ' Set the format to PDF
      .ExportFormatType = ExportFormatType.PortableDocFormat
      ' Set the destination options to DiskFileDestinationOptions object
      .DestinationOptions = CrDiskFileDestinationOptions
      .FormatOptions = CrFormatTypeOptions
End With
' Export the report to the PDF folder path
CR.Export()

Is there a way to stop the exporting process if the report is blank or has no records?   I was hoping to use something like size property, but I can't find it.

Any help would be tremendously appreciate it.
0
Comment
Question by:TheUndecider
4 Comments
 
LVL 4

Accepted Solution

by:
habibb earned 250 total points
Comment Utility
if you can check the datasource of report if its empty mean no records then you can stop exporting to pdf.
if its not possible for you to directly check datasource for example Dataset then you can get dataset from report document object and see if it  has data then proceed for pdf otherwise stop exporting to pdf.
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 250 total points
Comment Utility
There is a report property you can check but you must "display" the report then xport it.

I did this when we were displaying reports and tested the record count before making the viewer visible.  If there were no records then I simply displayed that message rather than showing a report.

This will increase processing time since the report is rendered twice.  Once for the hidden display then again for the export.

mlmcc
0
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Forced accept.

Computer101
EE Admin
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now