Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Crystal Report

Dear Experts,

I have a crystal report that requires some parameters. and after giving the parameters it populates the data as per the parameters. Now I want that these parameters should be passed by code and after that this report should be exported into PDF Format.

Is that possible to do ?

Plz help.

Regards

replied

Hi,

Here is a sample how to do it:

ReportDocument cryRpt = new ReportDocument();

string path = System.Windows.Forms.Application.StartupPath + @"\Customer Statement.rpt";

cryRpt.Load(path);

cryRpt.SetDatabaseLogon(ConfigurationSettings.AppSettings["sqluname"], ConfigurationSettings.AppSettings["sqlpass"], ConfigurationSettings.AppSettings["sqlserver"], ConfigurationSettings.AppSettings["dbname"], false);

cryRpt.SetParameterValue("CardCode@Select * from OCRD where Cardtype = 'C'", "C0015");

string FromDate = "20150103";

SAPbobsCOM.SBObob objBridge = (SAPbobsCOM.SBObob)SBO_Company.GetBusinessObject(BoObjectTypes.BoBridge);

string ValidFromDate = FromDate;

DateTime FromDt = Convert.ToDateTime(objBridge.Format_StringToDate(ValidFromDate).Fields.Item(0).Value);

string ToDate = "20150430";

string ValidToDate = ToDate;

DateTime ToDt = Convert.ToDateTime(objBridge.Format_StringToDate(ValidToDate).Fields.Item(0).Value);

          

cryRpt.SetParameterValue("fromdate", FromDt);

          

cryRpt.SetParameterValue("Todate@", ToDt);

          

ExportOptions CrExportOptions;

          

DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();

          

PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();

          

CrDiskFileDestinationOptions.DiskFileName = System.Windows.Forms.Application.StartupPath + @"\Mail" + "25" + ".pdf";

          

CrExportOptions = cryRpt.ExportOptions;

          

{

              

CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;

              

CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

              

CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;

              

CrExportOptions.FormatOptions = CrFormatTypeOptions;

          

}

          

cryRpt.Export();

Hope it helps.

Thanks & Regards

Ankit Chauhan

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question