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:
... this, like I said above, works like a charm!
The code that DOESN'T work (for exporting to HTML):
Any ideas? Even a VBScript example would be helpful!
Thanks!
--Geoff
Here's the code that works successfully to export to PDF:
Code:
#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!
The code that DOESN'T work (for exporting to HTML):
Code:
#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