SAP Knowledge Base Article - Public

1720176 - Exporting a report to HTML 40 format using Crystal Reports .NET SDK, application creates a folder at the specified location with report name.

Symptom

A web or Windows application to export the report to HTML 40, creates a folder at the specified location for exported file.

Environment

  • Visual Studio 2010
  • Crystal Reports for Visual Studio 2010 SP3

Reproducing the Issue

1. Develop a sample web application using below code.

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
    private DiskFileDestinationOptions diskFileDestinationOptions;
    private ExportOptions exportOptions;
    private string exportPath;
    protected void Page_Load(object sender, EventArgs e)
    {
        ReportDocument rd = new ReportDocument() ;
        rd.Load(Server.MapPath("Report1.rpt"));
          if (!System.IO.Directory.Exists(exportPath))
        {
            System.IO.Directory.CreateDirectory(exportPath);
        }
        diskFileDestinationOptions = new DiskFileDestinationOptions();
        exportOptions = rd.ExportOptions;
        exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        exportOptions.FormatOptions = null;
        exportOptions.ExportFormatType = ExportFormatType.HTML40;
        HTMLFormatOptions html40FormatOptions = new HTMLFormatOptions();
        html40FormatOptions.HTMLBaseFolderName = @"c:\test\html12\";
        html40FormatOptions.HTMLFileName = @"c:\test\html12\ExportedFile" ;
        html40FormatOptions.HTMLEnableSeparatedPages = true;
        html40FormatOptions.HTMLHasPageNavigator = true;
        html40FormatOptions.FirstPageNumber = 1;
        html40FormatOptions.LastPageNumber = 3;
        exportOptions.FormatOptions = html40FormatOptions;
        rd.Export();
    }
}
 

2. Observe the export location.

3. A folder gets created with the name of the report.

4. In this case report gets exported at "c:\test\html12\Report1\" instead of "c:\test\html12\"

Resolution

The solution is to use RAS:

ReportClientDocument.PrintOutputController.ExportEx(exportOpts1).Save("c:\test\html12\YourReportName.html", true);

ReportClientDocument.PrintOutputController.ExportEx(exportOpts1);

NOTE: there will be an Image folder created, no solution for this, it is by design.

Keywords

html4, rd.export, crvs, crsvs2010, crforvs2010, cr4vs2010, export issue , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , Bug Filed

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio