I know, this question has been asked many times and answered as well, but still can’t get it working while supplying parameters values, though without passing the parameter values, my Report is working fine with both PDF and Excel Export, please help me to fix this.
I’ve searched everywhere to get the right path to follow but no luck, below is my code.
I’ve tried this, but I’m getting error http://www.sitepoint.com/forums/showthread.php?486356-Inserting-date-parameters-into-a-Crystal-report
<?php
//- Variables - for your RPT and PDF
echo "Print Report Test";
$my_report = "C:\\AppServ\\www\\Acquiring\\reports\\rpt-group.rpt"; // rpt source file
$my_pdf = "C:\\AppServ\\www\\Acquiring\\reports\\TempFiles\\rpt-group.pdf"; // RPT export to pdf file
//-Create new COM object-depends on your Crystal Report version
$ObjectFactory= new COM("CrystalReports115.ObjectFactory.1") or die ("Error on load"); // call COM port
$crapp = $ObjectFactory-> CreateObject("CrystalDesignRunTime.Application"); // create an instance for Crystal
$creport = $crapp->OpenReport($my_report, 1); // call rpt report
//- Set database logon info - must have
$creport->Database->Tables(1)->SetLogOnInfo("SystemName", "DBName", "SQLServUser", "SQLServPWD");
//- field prompt or else report will hang - to get through
$creport->EnableParameterPrompting = 0;
//- DiscardSavedData - to refresh then read records
$creport->DiscardSavedData;
$creport->ReadRecords();
//—— Pass formula fields
//$creport->FormulaFields->Item(0)->Text = ("My Report Title");
$creport->ParameterFields(1)->AddCurrentValue("2016-08-26"); //CANNOT GET IT WORKING
$creport->ParameterFields(2)->AddCurrentValue("2017-08-26"); //CANNOT GET IT WORKING
//- export to PDF process
$creport->ExportOptions->DiskFileName=$my_pdf; //export to pdf
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1; // export to file
$creport->ExportOptions->FormatType=31; // PDF type | 29 Excel Type
$creport->Export(false);
//------ Release the variables ------
$creport = null;
$crapp = null;
$ObjectFactory = null;
//------And Now -> Embed the report in the webpage ------
print "<embed src='http://localhost:82/acquiring/reports/TempFiles/rpt-group.pdf' width=\"100%\" height=\"100%\">"
?>