C# .NET - Exporting a crystal report document to HTML format creates additional folders.

Asked By Abhinav Singh on 25-Aug-14 03:48 AM
Hi All,
I am trying to export a Crystal Report into HTML format. The code is below:

ReportDocument doc = null;
try
{
doc = BeforeRender(m_Rpt, format); -- Returns the ReportDocument object. 

DiskFileDestinationOptions DestOpt = new DiskFileDestinationOptions();
DestOpt.DiskFileName = "C:\Report_2014-08-25_1308.htm";

HTMLFormatOptions HTMLFmtOpt = new HTMLFormatOptions();
HTMLFmtOpt.HTMLBaseFolderName = Path.GetDirectoryName(fileName);
HTMLFmtOpt.HTMLFileName = fileName;

doc.ExportOptions.FormatOptions = HTMLFmtOpt;
doc.ExportOptions.DestinationOptions = DestOpt;
doc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
doc.ExportOptions.ExportFormatType = ExportFormatType.HTML40;

try
{
if (!Directory.Exists(OutputPath))
{
Directory.CreateDirectory(OutputPath);
}
doc.Export();
}
catch (Exception ex)
{
throw ex;
}
}

The problem here is when I execute this code, it creates the file at "C:\rptReport\Report_2014-08-25_1308.htm" instead of "C:\Report_2014-08-25_1308.htm" and also creates an image folder inside rptReport folder ("C:\rptReport\Images"). Please not that the rptReport is the name of the crystal report file ("rptReport.rpt"). This code works perfectly for pdf or rtf format but not for HTML.

I am not able to find the reason behind this. Please help.

Thanks in advance
Robbe Morris replied to Abhinav Singh on 25-Aug-14 11:16 AM
What is actually in "OutputPath" at runtime?

What are the actual values in your html options variables?

HTMLFmtOpt.HTMLBaseFolderName = Path.GetDirectoryName(fileName);
HTMLFmtOpt.HTMLFileName = fileName;

I'm not surprised that it creates an images folder.  If your report has any type of image (company logo perhaps), the export would dump the images out to individual files because HTML files do not include non-text objects like images.