
Invalid Export Options error when exporting a crystal report
Hi,
I've got a very weird problem when trying to export a Crystal Report.
Let me explain the application structure first because it is important
to understand what the real problem is:
an ASP page <-> a VB COM component <-> a .NET C# component interop as
a COM.
The .NET component uses the Crystal Report Engine to generate a report
and export it as a HTML file whose name will be fed to the ASP page as
a link, the next time when the link is clicked, the report will be
shown.
There are two types of reports defined: a plain one and a fancy one
with a couple of nice colour charts.
Now here is the weird thing:
1. I was able to get the plain report shown but when I let program to
create the fancy report, I always got "Invalid Export Options" error
from the report engine.
2. I've developed a test program to run the .NET C# component, it was
able to generate any report in the HTML format with no problem at all.
3. Both types of report actually used the exact same code (except the
different report templates and the datasets)
4. To make things more interesting, if I ran the VB component in a
debug mode (Yes, the one which had nothing to do with the report
generation), everything worked perfectly.
I think I could rule out the following:
1. It's not a security problem as one report works and the other
doesn't
2. I would doubt if it is a code problem as, again, both reports share
the same code, in addition, the test program was able to run the
report, so was in the debug mode.
I will appreciate if somebody could help me out as I am completely
puzzled.
Here is the code:
HTMLFormatOptions htmlFormatOptions;
DiskFileDestinationOptions fileOptions;
ExportOptions exportOptions;
ReportDocument report;
htmlFormatOptions = new HTMLFormatOptions();
htmlFormatOptions.HTMLEnableSeparatedPages = true;
htmlFormatOptions.HTMLHasPageNavigator = true;
htmlFormatOptions.FirstPageNumber = 1;
report = new ReportDocument();
exportOptions = new ExportOptions();
exportOptions = report.ExportOptions;
exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
exportOptions.ExportFormatType = ExportFormatType.HTML40;
exportOptions.FormatOptions = htmlFormatOptions;
// dbReportData is the dataset passed in
report.SetDataSource(dbReportData);
try
{
report.Export();
this.ready = true;
Quote:
}
catch (Exception e)
{
throw;
Quote:
}
finally
{
report.Close();
Quote:
}