Solved

Suppress Exporting Crystal Report as PDF IF No Data

Posted on 2007-12-06
4
1,487 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
ID: 20426907
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
ID: 20432724
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
ID: 20592627
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 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