Click here to Skip to main content
15,868,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
I am trying to export a Crystal Report into HTML format. The code is below:

C#
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900