Crystal_Report
-
I represented the data in Crystal Report based on certain conditions. which is stored in a table "abc" . I used CrystalReportViewer Control and my Crystal Report name is crystalreport1.rpt . and control name is crystalreportviewer1 I have a task to convert that report into pdf file and save into a folder(output) in Drive C: . and also to open that pdf file after creating the pdf. My question is what will be the C# code to convert Crystal Report into pdf files and stored in that folder of drive C: .
-
I represented the data in Crystal Report based on certain conditions. which is stored in a table "abc" . I used CrystalReportViewer Control and my Crystal Report name is crystalreport1.rpt . and control name is crystalreportviewer1 I have a task to convert that report into pdf file and save into a folder(output) in Drive C: . and also to open that pdf file after creating the pdf. My question is what will be the C# code to convert Crystal Report into pdf files and stored in that folder of drive C: .
I have converted this code from vb without testing, so please correct any syntax error ...
DiskFileDestinationOptions DiskOpts = New DiskFileDestinationOptions(); // export options to hard disk // oReport is a ReportDocument oReport.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile; // export option TYPE oReport.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat; // PDF file location and filename DiskOpts.DiskFileName = ExportPath + requiredFilename; // Destination options oReport.ExportOptions.DestinationOptions = DiskOpts; // Export oReport.Export(); // clear cr viewer and report document crViewer.ReportSource = null; oReport.Dispose(); oReport = null; // do this if you want to give the option to save or download the file, other wise go to Response.Redirect line at the end Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment; filename=filename.pdf"); Response.ContentType = "application/pdf"; Response.WriteFile(ExportPath + requiredFilename); Response.End(); // if you just want to open the the file then just do this and skip the above lines from Response.Clear to Response.End Response.Redirect(pdffilenameandpath, true);
-----
-
I represented the data in Crystal Report based on certain conditions. which is stored in a table "abc" . I used CrystalReportViewer Control and my Crystal Report name is crystalreport1.rpt . and control name is crystalreportviewer1 I have a task to convert that report into pdf file and save into a folder(output) in Drive C: . and also to open that pdf file after creating the pdf. My question is what will be the C# code to convert Crystal Report into pdf files and stored in that folder of drive C: .
A few statements from how I run a Crystal Report via a Windows Service: Defile is a FileInfo indicating the RPT file. reportfile is a FileInfo indicating the destination for the PDF.
CrystalDecisions.CrystalReports.Engine.ReportDocument crRpt =
new CrystalDecisions.CrystalReports.Engine.ReportDocument() ;
crRpt.Load ( Defile.FullName ) ;crRpt.SetParameterValue
(
parm.Key
,
parm.Value
) ;crRpt.ExportToDisk
(
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
,
reportfile.FullName
) ; -
I have converted this code from vb without testing, so please correct any syntax error ...
DiskFileDestinationOptions DiskOpts = New DiskFileDestinationOptions(); // export options to hard disk // oReport is a ReportDocument oReport.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile; // export option TYPE oReport.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat; // PDF file location and filename DiskOpts.DiskFileName = ExportPath + requiredFilename; // Destination options oReport.ExportOptions.DestinationOptions = DiskOpts; // Export oReport.Export(); // clear cr viewer and report document crViewer.ReportSource = null; oReport.Dispose(); oReport = null; // do this if you want to give the option to save or download the file, other wise go to Response.Redirect line at the end Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment; filename=filename.pdf"); Response.ContentType = "application/pdf"; Response.WriteFile(ExportPath + requiredFilename); Response.End(); // if you just want to open the the file then just do this and skip the above lines from Response.Clear to Response.End Response.Redirect(pdffilenameandpath, true);
-----