×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Exporting a Crystal Report to HTML in Perl Fails

Exporting a Crystal Report to HTML in Perl Fails

Exporting a Crystal Report to HTML in Perl Fails

(OP)
I've been struggling with exporting a report to HTML in Perl (or VBScript for that matter.)  I've successfully exported to a PDF format file, but for some reason, the export to HTML doesn't work.  I'm using the RDC, Crystal 8.5.

Here's the code that works successfully to export to PDF:


#CrystalToPDF.pl
# Prototype for exporting a Crystal Report to PDF format in Perl
#Modification History:
# 31-AUG-2001: GGARIEPY: [creation]

use strict;
use Win32::OLE;
use Win32::OLE::Variant;

# Produce a OLE Variant "FALSE" to pass to the Export method...
my $false = Variant(VT_BOOL,0);

# Create a connection to the Crystal Reports Application via the RDC COM object
my $rdapp = Win32::OLE->new('CrystalRuntime.Application') || die "Couldn't create CrystalRuntime.Application.  Is it installed?\n";

# Programmatically open a report template
my $report = $rdapp->OpenReport('d:\document files\perl\crystal\SendReceive_pw_nodata.rpt');

# Tell the Crystal application to read the records in using the SQL query embedded in this report template
$report->ReadRecords;

# De-reference the ExportOptions object (represented as a hash, like all Perl OLE constructs)
my $exportopt = $report->ExportOptions;

# Tell the export options to {DestinationType = 1} send to a disk file, the {DiskFileName} and the file format {FormatType} = PDF
$exportopt->{DestinationType} = 1;
$exportopt->{DiskFileName} = 'exportfile.pdf';
$exportopt->{FormatType} = 31;

# Tell the Crystal Application to hide the GUI Progress Dialog box and export the report without prompting the user interactively
$report->{DisplayProgressDialog} = $false;
$report->Export($false);

# We're done!

... this, like I said above, works like a charm!

The code that DOESN'T work (for exporting to HTML):

#CrystalToHTML.pl
# Prototype for exporting a Crystal Report to HTML format in Perl
#Modification History:
# 31-AUG-2001: GGARIEPY: [creation]

use strict;
use Win32::OLE;
use Win32::OLE::Variant;

# Produce a OLE Variant "FALSE" to pass to the Export method...
my $false = Variant(VT_BOOL,0);
my $true = Variant(VT_BOOL, 1);

# Create a connection to the Crystal Reports Application via the RDC COM object
my $rdapp = Win32::OLE->new('CrystalRuntime.Application') || die "Couldn't create CrystalRuntime.Application.  Is it installed?\n";

# Programmatically open a report template
my $report = $rdapp->OpenReport('d:\document files\perl\crystal\SendReceive_pw_nodata.rpt');

# Tell the Crystal application to read the records in using the SQL query embedded in this report template
$report->ReadRecords;

# De-reference the ExportOptions object (represented as a hash, like all Perl OLE constructs)
my $exportopt = $report->ExportOptions;

# Tell the export options to {DestinationType = 1} send to a disk file, the {HTMLFileName} and the file format {FormatType} = HTML
$exportopt->{DestinationType} = 1;
$exportopt->{HTMLFileName} = 'exportfile.html';
$exportopt->{HTMLEnableSeparatedPages} = $true;
$exportopt->{HTMLHasPageNavigator} = $true;
$exportopt->{FormatType} = 32;

# Tell the Crystal Application to hide the GUI Progress Dialog box and export the report without prompting the user interactively
$report->{DisplayProgressDialog} = $true;
$report->Export($false);

# We're (not) done!


Any ideas?  Even a VBScript example would be helpful!

Thanks!
--Geoff

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close